Pass Parameters in render - Rails 3

To do it your way:

In the main view:

<% fbookupload = "yes" %>
<%= render :partial => '/memory_books/new', :locals => {:fbookupload => fbookupload} %>

And in the partial:

<%= fbookupload %>

2nd option:

Ideally in the controller, otherwise in the view, define an instance variable: @fbookupload = "yes". Then it is available everywhere. The partial will then be : <%= @fbookupload %>


try this:

<%= render :partial => '/memory_books/new', :locals => {:fbookupload => "yes"} %>

Taking it out of the comments for posterity. This syntax is correct:

render '/memory_books/new', fbookupload: "yes"

But if there is a reference to rendering the same partial without specifying the local variables, e.g.

render '/memory_books/new'

then fbookupload variable becomes unavailable. The same applies to multiple local variables, e.g.

render 'my_partial', var1: 'qq', var2: 'qqq'

will work if only occurs once. But if there is something like that somewhere else in the code

render 'my_partial', var1: 'qq'

then the var2 will become unavailable. Go figure ...