I’m doing the following:
<%= render :partial => "folder/content", :locals => {:var1 => featured_content, :featured => true} %>
Inside the _content.html.erb partial, I can access the first local variable fine. var1 works great. However, the second local variable is having problems.
I put a call to the debugger right before the line I want to use the featured variable. I can access that variable (and its value) just fine. In fact, in the debugger, I can list all the local variables … and I see that “featured” is one of them.
But when I run my server, I get the following error:
undefined local variable or method `featured' for #<#<Class:0x002g9ff8617940>:0x007f9aa251eb38>
What could possibly be happening here? It makes no sense to me at all!
UPDATE:
If I do the following:
<% if local_assigns.has_key? :featured %>
<% 'hello world' if featured %>
<% end %>
then everything works perfectly fine. However, if featured is not within the scope of the if statement, then I get an error.
This is total madness as far as I can see — I would love some insight into what is happening and why its happening only to this one poor variable (the other variable is completely fine mind you…).
Looks like the has_key is the only option that works right now (please see my edit). I am going to close this since I haven’t gotten any better responses.