Sintaxis de la sentencia Rails if


He escrito el siguiente ERB y estoy recibiendo un error de sintaxis en el signo de interrogación. Esta función auxiliar de devise se evalúa actualmente como false. ¿Qué me he perdido?

<%= if user_signed_in? %>
<%= render 'form' %>
<%= end %>
Author: eugen, 2011-07-15

3 answers

Prueba esto:

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

Si lo hace , intentará generar la cosa que pones entre las etiquetas. Pero, si lo haces , entonces no se procesa ninguna salida, solo se evalúa el código. Si esto no está funcionando, entonces probablemente hay algo mal con su user_signed_in? método de ayuda.

 76
Author: SteenhouwerD,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-10 21:04:43

<%= intentará generar tu ayudante user_signed_in?, así que intenta:

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

O incluso mejor (y menos confuso):

<%= render 'form' if user_signed_in? %>
 24
Author: Mario Uher,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-07-15 12:40:50

Prueba esto

<% if user_signed_in? %>
    <%= render 'form' %>
<% end %>
 2
Author: Mahesh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-15 16:42:45