Flowdock

Good notes posted by Manfred

RSS feed
June 22, 2009
3 thanks

Optional local assigns

When you have a partial with optional local assigns, for instance:

<%= render :partial => 'articles/preview' %>
<%= render :partial => 'articles/preview', :locals => { :show_call_out => true } %>

And you don’t want the partial to break when the local isn’t assigned, you can reference it through the local_assigns local variable instead of through the template binding:

<% if local_assigns[:show_call_out] %>
  <em><%= format @article.call_out %></em>
<% end %>