Ok, here it is
Main Topics
Browse All TopicsHi there,
i'm having a hard setting up a select list in a rails form.
I want the select list to update a field called 'artist_cat' in a table called "artists" with the id value of a table called "categories", and i want the list of choices to be the value categories.name.
The box itself appears but the field 'artist_cat' is not updated...
i don't understand what's wrong with my code...
Any ideas ?
Cheers,
Terence
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Okay, you ARE update the artist_cat value:
UPDATE artists SET `bio` = '', `name_fr` = 'Alexandra Maria Lara', `name` = 'Alexandra Maria Lara', `bio_zh` = '', `artist_cat` = 0, ...
What makes you think that you aren't updating the value?
You should probably redirect_to :list after a successful update, too. Why re-render when you can redirect?
well, i see the field, but for some reason, the value passed to the update action is always the value that in current in the database and not the selected one.
here is the generated drop down list code, which moreover is correct...
so i assume there is something being reinitialized somewhere in the controller, am i correct ?
Do you have another artist_cat field there? Maybe a hidden field or something?
Everything looks fine to me. I don't see a re-initialization in the controller, just the update_attributes() call.
Your option values look correct. In fact, it looks the db is set to value 2 in the code snippet you just posted because it was set to be selected by default.
Business Accounts
Answer for Membership
by: wesgarrisonPosted on 2009-05-07 at 21:07:51ID: 24332976
What does your update action look like?
Paste your update action for this form and the params when submitting the form and we'll check them out to see what's going on.