データベースに列挙型フィールドを作成しました。次に、選択可能なすべての値が表示されるように、フィールドをビューにバインドします。この場合、男性と女性です。
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)