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.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.