我在数据库中创建了一个枚举字段。现在我想将字段绑定到视图,使其显示所有可用值以供选择。在这种情况下男性和女性。
t.enum :sex ,:limit => [:Male, :Female]
编辑:
SQL generated:
Started PUT "/profiles/3" for 127.0.0.1 at 2012-06-04 22:11:35 -0700
Processing by ProfilesController#update as 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].* FROM [profiles] WHERE [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 to http://localhost:3000/profiles/3
Completed 302 Found in 5ms (ActiveRecord: 2.0ms)