Hi, I have a model Post that I want to assign to section, sub_section and sub2_sections. My models are set up as follows...
Post belongs_to :section belongs_to :sub_section belongs_to :sub2_section Section has_many :sub_sections Sub_Section belongs_to :section has_many :sub2_sections Sub2_Sections belongs_to :sub_section I have a form that is using AJAX requests to populate 3 collection_select menus in turn. (Choose a section which populates sub_section, choose a sub_section which populates sub2_section. This all works great and I can submit the form, the post is saved... in the logs you can see that "sub2_section_id" which is a column in my Post table is set to "4" but when it goes to insert it into the table it becomes "NULL" When you go back into the post to edit it, obviously, hasn't recorded the sub2_section and it appears blank (but with the correct sub2_sections in the dropdown again. -------------------------------------------------------------------------------- Started POST "/posts" for 127.0.0.1 at Sun Mar 25 14:06:19 +0100 2012 Processing by PostsController#create as HTML Parameters: {"commit"=>"Create Post", "post"=>{"brand"=>"Test Brand", "title"=>"Test Product", "sub_section_id"=>"2", "quantity"=>"", "section_id"=>"1", "sub2_section_id"=>"4", "weight"=>"50g", "manufacturer"=>"", "volume"=>"", "status"=>""}, "authenticity_token"=>"E0WVeTZ/v+EjkCtGCuNiMtEoOQAL8FciQZGgK1hrJNE=", "utf8"=>"\342\234\223"} (0.2ms) BEGIN SQL (0.4ms) INSERT INTO `posts` (`brand`, `created_at`, `department`, `manufacturer`, `quantity`, `section_id`, `status`, `sub2_section_id`, `sub_section_id`, `title`, `updated_at`, `volume`, `weight`) VALUES ('Test Brand', '2012-03-25 13:06:19', NULL, '', '', 1, '', NULL, 2, 'Test Product', '2012-03-25 13:06:19', '', '50g') (1.3ms) COMMIT Redirected to http://0.0.0.0:3000/posts/43 Completed 302 Found in 12ms (ActiveRecord: 1.9ms) -------------------------------------------------------------------------------- It is recording section_id and sub_section_id perfectly in the posts record but not sub2_section_id Any ideas, help or pointing out of obvious idiocy are very welcome! 3quid -- Posted via http://www.ruby-forum.com/. -- 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.