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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 18, '11 at 8:26a
activeNov 18, '11 at 8:26a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Mauro: 1 post

People

Translate

site design / logo © 2022 Grokbase