2016-01-26 74 views
0

我有這樣的代碼:如果其他軌道語法錯誤,意想不到的「;」,期待「:」

<% 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 -%> 

我想要做的是檢查,如果我@lead存在,顯示鉛和一些圖片或說db中沒有找到這樣的記錄。如果我帶走,如果別人和留下這個

/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...

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

錯誤自敗,但它給了我一個錯誤。 我該如何解決這個問題?

回答

1

只要使用此:

<% 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 %> 

這應該工作和解決您的問題。

+1

它的工作原理!謝謝!)) – user2950593

+0

是的,我沒有立即接受,因爲我有7分鐘延遲才接受=) – user2950593

相關問題