In rails 3, how to create a Dropdown from hash
I have following code in my User class
class User
… other codes
key :gender, Integer # i use mongo db
class << self
def genders() # not sure how to define static value, so
do in
this way
genders = {
‘1’ => ‘Male’,
‘2’ => ‘Female’,
‘3’ => ‘Secret’
}
end
end
end
In the user form, i am trying to create a gender dropdown list
<%= f.collection_select nil, :gender, User.genders, :key, :value %>
but it complain
undefined method `merge’ for :value:Symbol
So what is the proper way to create the dropdown?
Thanks
–
View this message in context:
http://old.nabble.com/how-to-create-dropdown-from-a-hash-in-rails-3-tp32043403p32043403.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.