Thanks super, Colin--that really helps. I believe category_id is being passed, as in the development.log
Processing ItemsController#update (for ::1 at 2009-09-25 06:34:23) [PUT] Parameters: {"commit"=>"Update", ... "id"=>"228", "item"=> {..."category_id"=>["2"], ...}} [4;35;1mPage Load (1.1ms) [0m [0mSELECT * FROM "pages" ORDER BY position [0m [4;36;1mUser Load (0.6ms) [0m [0;1mSELECT * FROM "users" WHERE ("users"."id" = 1) LIMIT 1 [0m [4;35;1mItem Load (0.7ms) [0m [0mSELECT * FROM "items" WHERE ("items"."id" = 228) [0m Redirected to http://localhost:3000/items/228 Completed in 102ms (DB: 2) | 302 Found [http://localhost/items/228] and for different updates, the number in category_id [ ] is changing. In my controller, I have the provided boilerplate for update: def update @item = Item.find( params[ :id ] ) respond_to do |format| if @item.update_attributes(params[:item]) ... Am I missing something in the controller? Does a collection need to be handled separately? Many TIA, Craig On Sep 25, 2:36 am, Colin Law <clan...@googlemail.com> wrote: > 2009/9/25 Dudebot <craign...@gmail.com>: > > > > > > > > > Hi Gurus, I'm trying to tackle a drop down list. I have category and > > item dbs, and they're wired up with category has_many :items and item > > belongs_to :category, and an item has a category_id. I have this code > > in my new/edit.html.erb for item: > > > <%= f.collection_select :category_id, > > Category.find_main, :id, :header, {}, :multiple => false %> > > > And a pretty drop down list comes up, but no matter what I do, I can't > > save an item with a different category--it always stubbornly records > > the same one (or doesn't change it at all). The source html code > > generated is: > > > <select id="item_category_id" name="item[category_id][]"><option > > value="3">Awesome Things</option> > > <option value="1" selected="selected">Good Things</option> > > <option value="2">Better Things</option></select> > > > ...and although I can "choose" a different category for an item than > > 'Good Things', it only records 'Good Things' (category_id 1) for all > > items. > > The first thing to do is to look in your log file (log/developent.log) > to check that the selection is being passed in params. If it is then > consider whether what the controller action that you are passing it to > is doing with it. > > Colin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---