What is...">

Why use like <% and <% = in views?

If I write something like:

<% if signed_in?.blank? %> or <%= link_to "Sign Up", sign_up_path %>

What is the difference between the two signs <%and <%=?

Why do it this way instead of just using one for simplicity?

When do I know I need to use <%over <%=?

+5
source share
2 answers

<%= puts the return value of the code inside the page.

<% just execute the code.

Here is a good guide to ERB http://api.rubyonrails.org/classes/ActionView/Base.html

+10
source

<% %> , <%= %> .

, , <% if signed_in?.blank? %> ruby ​​ , signed_in .

<%= link_to %> HTML.

+1

All Articles