Reputation: 9627
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?
Upvotes: 0
Views: 717
Reputation: 34338
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.
Upvotes: 1