Rails 3 - collection_select - Understanding PROMPT?

I am creating a form that allows a CRUD user to resolve a project.

....

<% roles = Role.all %>
<%= f.collection_select :role_id, roles, :id, :name, :prompt => true %>

Problems with the above while it displays:

  • If the value matches, it shows that a dropdown is selected, which is good. The problem is if the user is configured as ADMIN. It's easy to use the drop-down list to change the permission to something else but not clear the permission ...

Example ... Select Drop Down: - Please select - Admin - Member - Guest

If an administrator is selected, select "Never appears" .... How can I make a choice so that the user can delete the setting?

Any ideas? THX

+5
source share
2 answers

, :

<%= f.collection_select(:role_id, roles, :id, :name, {:include_blank => 'Please Select'} %>

. FormOptionsHelper.

+15
<% roles = Role.all %>
<%= f.collection_select :role_id, roles, :id, :name, :prompt => (@user.admin? ? true : false) %>

?

, admin/not.. , : prompt..

lemme , :)

+1

All Articles