Form_for and belongs_to

Let’s say I have a simple RESTful scaffold named: product

and the new and edit forms contain something like:

<% form_for( @product ) do |f| %>

<%= f.text_field :name %>

<% end %>

Everything is cool and working. Now, let’s say I want to use a
belongs_to in product.rb

class Product

belongs_to :some_other_model, blah, blah…

end

Is it possible to do something on the product form to reference
some_other_model and capture form field values??

I’m thinking something along the lines of:

<% form_for( @product ) do |f| %>

<%= f.text_field :some_other_model.other_name %>

<% end %>

or whatever the syntax would be…

Thanks

you would wrap these in a fields_for block. ie

<% form_for( @product ) do |f| %>

<%= f.text_field :some_other_model.other_name %>

<% fields_for :some_other_model do |o| %> <%= o.text_field o.other_name %> <% end %> <% end %>