2009/9/25 Dudebot <[email protected]>: > > 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 [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 -~----------~----~----~----~------~----~------~--~---

