I've been googling around about this and can't find the right path. I'm working on a Rails app that is using a method called local_assigns. This appears to be something in Rails or a gem, and not specific to my app, but it's used for rendering a partial in different contexts, such as this:
<% if local_assigns[:custom_name] %>
<li><%= custom_name %></li>
<% else %>
or also this:
<%= render "discussions/complementary/#{local_assigns[:action] || params[:action]}" %>
Is this is Rails method? Where can I find more documentation about this?
local_assigns
is a Rails view helper method that you can check whether this partial has been provided with local variables or not.Here you render a partial with some values, the
headline
andperson
will become accessible with predefined value.In
shared/header
view:Here is how you check these variables has passed in or not:
Check this document for more detail on the section Passing local variables to sub templates.