I'm assuming this is rails 3. For your edit action you don't need the @document variable. You can refer to all of your documents via the :has_many association you created in the model so @shop.documents will suffice.
Your fields_for will need to look something like this fields_for :documents, @shop.documents |ff_item| stuff for whatever you need (text area's checkboxes etc.) end If you want to access your data from your document in the fields_for loop, you can do "ff_item.object.DOCUMENT_METHOD". ff_item.object will be an instance of your document so you can set the default values for your html items. Vinny @agnellvj > I've found that is more simpler than I've thought. > > Models are: > > Shop has_many :document, Document belongs_to :shop. > > For edit action I've done: > > @shop = Shop.find(params[:id]) > @document = @shop.documents.new > > and in the form I've done: > > fields_for @document. > > Now I can modify an existing shop and at the same time add a document. > Do you think it's all correct? > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/C7wW_K6mXW0J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

