Rails if statement syntax Rails if statement syntax ruby-on-rails ruby-on-rails

Rails if statement syntax


Try this :

<% if user_signed_in? %>  <%= render 'form' %><% end %>

If you do <%= ... %>, it will try to output the thing you put between the tags. But, if you do <% ... %>, then no output is processed, just the code is evaluated. If this is not working, then there is probably something wrong with your user_signed_in? helper method.


<%= will try to output your user_signed_in? helper, so try:

<% if user_signed_in? %>  <%= render 'form' %><% end %>

or even better (and less confusing):

<%= render 'form' if user_signed_in? %>


try this

<% if user_signed_in? %>    <%= render 'form' %><% end %>