I have a Rails form that is being used for creating and editing a model with a has_many relationship. I'm very familiar with typical forms with nested models, but my current problem requires accessing rendering some form elements using typical FormBuilder helpers and other HTML elements using data from the model itself. For example, my top level form has something like:
<% customer_form.fields_for :customer_images do |images_form| %>
<%= render :partial => 'customer_image_show', :locals => { :f => images_form } %>
<% end %>
Then, in the form partial, I need to do something like:
<dd><%= f.text_field :image_description %></dd>
... but also access attributes from the customer_images model (for example, the ID of the customer_image record).
I feel like this should be pretty straightforward and I'm just missing something basic. Any help is appreciated. This is a Rails 2.3.8 application.
You can call
f.object
to get to the object that the form is associated with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With