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
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Alan Bullock
Sent: Wednesday, April 12, 2006 11:30 PM
To: rails@lists.rubyonrails.org
Subject: [Rails] acess local variables from helper?
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
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails