Ruby on Rails 4 select multiple -
i have form creates new users. trying add drop down option select permission levels. want able select multiple permission levels per user.
this view, added {:multiple => true} :
<%= f.label :permission, "permission level" %> <%= f.select :permission, [ ["read only", "read"], ["ip voice telephony", "ip_voice"], ["ip video telephony", "ip_video_telephony"], ["enterprise gateways", "enterprise_gateways"], ["consumer atas", "consumer_atas"], ["ip pbx", "ip_pbx"], ["master of all", "all"] ], {prompt: "select permission level"}, {:multiple => true}, class: "input-lg" %> my controller, added :permission => [] :
def user_params params.require(:user).permit(:name, :email, :password, :password_confirmation, :admin, :permission => []) end the error view, f.select:
wrong number of arguments (5 2..4) how make select multiple rails 4?
class , multiple both part of html_options, should go in single hash.
change
<%= f.select :permission, [ ["read only", "read"], ["ip voice telephony", "ip_voice"], ["ip video telephony", "ip_video_telephony"], ["enterprise gateways", "enterprise_gateways"], ["consumer atas", "consumer_atas"], ["ip pbx", "ip_pbx"], ["master of all", "all"] ], {prompt: "select permission level"}, {:multiple => true}, class: "input-lg" %> to
<%= f.select :permission, [ ["read only", "read"], ["ip voice telephony", "ip_voice"], ["ip video telephony", "ip_video_telephony"], ["enterprise gateways", "enterprise_gateways"], ["consumer atas", "consumer_atas"], ["ip pbx", "ip_pbx"], ["master of all", "all"] ], {prompt: "select permission level"}, {:multiple => true, class: "input-lg"} %> right passing them separately. so, argument count select method becoming 5 when should 4. hence, error.
Comments
Post a Comment