ruby - How to bind enum value to a field in rails -
i have created enum field in database. want bind field view in such way shows available values selection. in case male , female.
t.enum :sex ,:limit => [:male, :female] edit:
sql generated: started put "/profiles/3" 127.0.0.1 @ 2012-06-04 22:11:35 -0700 processing profilescontroller#update html parameters: {"utf8"=>"?", "authenticity_token"=>"ijgsa4rfvebc/lwd6pi69rj5o0rxmpntu7pavqk5hpm=", "profile"=>{"firstname"=>"huzaifa ", "sex"=>"female"}, "commit"=>"update profile", "id"=>"3"} [1m[36mprofile load (1.0ms)[0m [1mexec sp_executesql n'select top (1) [profiles].* [profiles] [profiles].[id] = @0', n'@0 int', @0 = 3[0m [["id", "3"]] [1m[35msql (0.0ms)[0m begin transaction [1m[36mcache (0.0ms)[0m [1mselect @@trancount[0m [1m[35msql (0.0ms)[0m commit transaction redirected http://localhost:3000/profiles/3 completed 302 found in 5ms (activerecord: 2.0ms)
a range of values can presented in number of ways in form, sounds want selecte field. i'm assuming column name "enum"
= form_for @<model_name> |t| = t.select :enum, [:male, :female]
Comments
Post a Comment