I’m getting confused.
If I have a view (.rhtml), I can use a field helper like:
<%= text_field :mymodel, :attribute %>
This uses the value from @mymodel.attribute
Now, if I am rendering a template normally (i.e. not partial), I would
expect @mymodel to be a model object defined as an instance variable in
the controller.
However, if I am rendering a partial template, I either have:
render :partial => ‘mything’, :object => @mymodel
or
render :partial => ‘mything’, :collection => @mymodelcollection
Now, inside the template, the @mymodel object is available as the
local variable mything (same as template name).
If I have a field helper, I cannot now use:
text_field :mything, :attribute
because text_field expects @mything (an instance variable).
I can get around this my putting at the top of my partial template:
<% @mything = mything %>
but this seems a little clunky and un-Ruby-ish. Is there a better way?
Thanks,
Julian