I\'m learning Rails, and i\'m doing a exercise which i have to mix some html with ruby in a view file.
What is the main difference between \" <%= #code %> \" and \" &
<%= something which you would like to have displayed in your view %>
<% something you would like to have hidden,
(or something which doesn't display anything in the view) such as a
conditional statement %>
<% if @post.nil? %>
<%= render "nilNotify" %>
<% else %>
<%= @post.content %>
<% end %>
<%= 1 + 2 %>
will evaluate AND display the result.
In this case, you should see 3 in your view.
<% 1 + 2 %>
will evaluate but will not display the result in the view. In this case, you will not see 3 in your view.