How to access local parameters in partials?

In my template, I call this partial with an additional parameter:

<%= render :partial => "shared/finder_list_header.html.erb", :locals => { :selectFinder => true } %> ...

Inside the partial I try to access selectFinder:

<% if selectFinder %>


<% end %>

and get an error message:

undefined local variable or method `selectFinder’ for
#ActionView::Base:0xb6ef1f58

What is going wrong?

Fritz T. wrote:

In my template, I call this partial with an additional parameter:

<%= render :partial => "shared/finder_list_header.html.erb", :locals => { :selectFinder => true } %> ...

Inside the partial I try to access selectFinder:

<% if selectFinder %>


<% end %>

and get an error message:

undefined local variable or method `selectFinder’ for
#ActionView::Base:0xb6ef1f58

What is going wrong?

Hum. It looks like you’re basically do it right. I do this quite a bit
in my partials. The only thing I see is that you’re not following Ruby
conventions. Ruby does not use camel case for variable/symbols. It
should be :select_finder and select_finder instead of using camel case.

I also don’t normally use them for passing in constant values as in {
:select_finder => true }. So I threw together a quick test program and
everything seems to be working as expected.

<%= render :partial => ‘parts’, :locals => { :select_finder => true }

In the partial…

<% if select_finder %>


<% end %>

Thanks for your reply.
Changeing selectFinder to select_finder doesn’t help.

It was my fault, sorry.