Reputation: 1757
Can any one help me in creating a drop down list in rails. I'm having a user table with a role field and I want to create a drop down list with values manager, investigator, director for role.How I can extract this value to parms[:role] . I'm new to rails.
Upvotes: 2
Views: 4601
Reputation: 1160
If you are using form_for (not form_tag), then it should go like this.
<%= form_for @user do |f| %>
...
<%= f.select :role, options_for_select(%w[manager investigator director]) %>
<% end %>
Then you'll have params[:user][:role]
available in your controller.
Refer this for more info on select helper.
Upvotes: 5