I have a Shop and a Document model.
Shop has_many :documents and Document belongs_to :shop.
I want to create a document associated to a shop.
routes.rb has:
resources :shops do
    resources :documents
end

In the document form I've set:

 = f.input :shop_id, :as => :hidden if @document.new_record?

I'm using simple_form.
When I submit the form the document is created but is not associated
to the shop.
It works if I do @document = Document.new(:shop_id =>
params[:shop_id]) in the new action.
Why I have to specify shop_id attribute?
shop_id is a document attribute so I think that I do not specify it on
document creation.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to