<%=outputs the result of Ruby. <%just evaluates Ruby.
<p>Hi! How are you? 1 + 1 = <%= 1 + 1 %></p>
Will be <p>Hi! How are you? 1 + 1 = 2</p>.
<p>Hi! How are you? 1 + 1 = <% 1 + 1 %></p>
It will become <p>Hi! How are you? 1 + 1 = </p>.
<%commonly used for flow control, for example. if/else. Example:
<% if model.nil? %>
<%= render 'new_model_form' %>
<% else %>
<%= render 'detail_view' %>
<% end %>
Read more at http://guides.rubyonrails.org/layouts_and_rendering.html
source
share