views:

48

answers:

2

I'm just getting started with Ruby and Ruby on Rails, so excuse me if this is a simple question. I've noticed that in some ERB files, there is a difference to using <%= %> and <% %>, but what is the difference?

Thanks!

+3  A: 

Hi, The difference is as follows:- <%= %> would execute and print the value of rails code written inside and <% %> would just execute the rails code.

Thanks, Anubhaw

Anubhaw
You can also do <%= -%>. The minus at the end removes the newline. Useful for formatting the generated HTML.
Jaco Pretorius
A: 

<%= %> in ERB equals to <?php echo ?> in PHP.

Shinya Miyazaki