0

I have this code:

<% if @lead? -%>
    <h3>Current status of your car is <%= @lead.status %> </h3>
    <%=image_tag("stat/" + @lead.status + ".jpg", :class => "status_image", alt: "status")%>
<% else -%>
    <h3> No records found.</h3>
<% end -%>

What I want to do is to check if my @lead exists and show lead and some picture or say that such records in db were not found. But it gives me an error:

/home/jonstark/rails_projects/car_main/app/views/static_pages/check_lead_car_status.html.erb:4: syntax error, unexpected ';', expecting ':' ...urrent status of your car is ';@output_buffer.append=( @lead...

If I take away if else and leave just this:

<h3>Current status of your car is <%= @lead.status %> </h3><br/><br/>
        <%=image_tag("stat/" + @lead.status + ".jpg", :class => "status_image", alt: "status")%>

The error dissapears. How do I fix this?

1 Answer 1

1

Just use this:

<% if @lead %>
    <h3>Current status of your car is <%= @lead.status %> </h3>
    <%=image_tag("stat/" + @lead.status + ".jpg", :class => "status_image", alt: "status")%>
<% else %>
    <h3> No records found.</h3>
<% end %>

This should work and fix your problem.

Sign up to request clarification or add additional context in comments.

1 Comment

yeah I didn't accept it immediately cause I had 7 min delay before accepting=)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.