0

coming from Django I am wondering how rails people think about <%= %> vs <% %>

From what I see here <%= tag.title %> displays information that's already present like attributes of the obj, like the {{ }} in django, and <% %> always does stuff, like an each loop or if statement, like the {% %} in django.

If that statement fully accurate, or is there a finer line I missed? Thanks

codyc4321
  • 6,868
  • 17
  • 63
  • 129
  • 2
    possible duplicate of [What is the difference between in ERB in Rails?](http://stackoverflow.com/questions/7996695/what-is-the-difference-between-and-in-erb-in-rails) – Pavan Aug 25 '15 at 14:42

1 Answers1

2

Yeah you've basically got it down.

<% %>

Will run ruby code without displaying it

<%= %>

Will display the information to the screen

<%# %>

Will comment out ruby code in your view

Here's just a simple example

<% @users.each do |user| %>
  <%= user.email %>
<% end %>

This question may help you as well.

Community
  • 1
  • 1
thedanotto
  • 4,915
  • 4
  • 37
  • 39