if I call a helper method from inside a partial, it doesn’t appear to
have
access to the partials local variables. is there a way to make them
avilable
without passing them as parameters?
here’s a simple example
in the view
<%= render :partial => “my_partial”, :locals => :value => 2%>
_my_partial.rhtml - raises "undefined local variable or method
`value’"
<%= show_value %>
helper method
def show_value
value
end
My first thought is that you could make value an attribute (though that
means they’re no longer local), so you’d have
in the view
<% @value = 2 %>
<%= render :partial => “my_partial” %>
_my_partial.rhtml - raises "undefined local variable or method
`value’"
<%= show_value %>
helper method
def show_value
@value
end
But to me it seems better to just pass your values in as parameters.
Daniel
“Daniel H.”
[email protected] wrote in message
news:[email protected]…
My first thought is that you could make value an attribute (though that
means they’re no longer local), so you’d have
I’m not sure if instance variables are practical in this case because
the
partial gets rendered many times (as a collection). Thanks for your
suggestion though.