newbie question: how to show a drop down menu with this function

Posted by Mellon on Stack Overflow See other posts from Stack Overflow or by Mellon
Published on 2011-01-13T12:49:49Z Indexed on 2011/01/13 12:53 UTC
Read the original article Hit count: 401

My model object (e.g. MyObject) has one property (e.g. color), the "color" property holds a string value which comes from a list of string (e.g. colors=['red','yellow', 'black']).

now, I have one instance of myObject get from database and show on the view page in a row, I need to show the 'color' property of myObject in a drop down menu with the current value as the default selected. How to implement this in Rails 3 in my view page.

(Later, when user select from the dropdown menu, the object will be updated in DB based on user's selection)

Please explain with instance "myObject" and list "colors=[...]"

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby-on-rails3