You can also look at the options: locals for rendering. Which accepts the hash, so the keys are characters that map to local variable names in your template, and the values ββare the values ββfor setting these local variables.
Example:
render "show", :locals => {:user => User.first, :some_other_variable => "Value"}
and this template
User ID: <%= user.id %><br> Some Other Variable: <%=some_other_variable%>
will produce:
User ID: 1<br> Some Other Variable: Value
When you reuse partial elements for multiple controllers. Setting local variables with the: locals option is simpler and much more DRY than using instance variables.
Emfi
source share