I used declarative_authorization for my app and had problem with creating new user.
my User model code:
class User < ActiveRecord::Base ROLE_TYPES = ["admin", "user", "guest"] validates_inclusion_of :roles, :in => ROLE_TYPES def role_symbols @role_symbols ||= (roles || []).map{|r| r.to_sym} end
my view code:
<% form_for(@user) do |f| %> ... <p> <%= f.label :roles %><br /> <%= f.select :roles, User::ROLE_TYPES, :prompt => "Select a role" %> </p> <%= f.submit 'Add User' %> <% end %>
every time i tried to create a new user and select the role from the drop-down list, the view complaint:
Roles is not included in the list
from the output of the script/server, i can see the roles was actually set:
"user"=>{"name"=>"kc", "password_confirmation"=>"kc", "roles"=>"guest", "password"=>"kc", "email"=>"[email protected]"}
can anyone tell me what's wrong? why the validation wont' pass?