do i need to declare the relations in User model

1 view
Skip to first unread message

daociyiyou

unread,
Aug 17, 2009, 9:54:26 AM8/17/09
to Rails Authorization Plugin
hi
I am using the rails_authorization_plugin,but i have a question to
ask.After configure the plugin,i have relations among the
User,Role,RolesUser models,but i notice the relations declaration only
appear in the Role and RolesUser model,not in the User model.Do i
need to declare the relations in User model to make plugin work
properly?

##########
class Role < ActiveRecord::Base
has_many :roles_users, :dependent => :delete_all
has_many :users, :through => :roles_users
belongs_to :authorizable, :polymorphic => true
acts_as_authorizable
end

#######################
class RolesUser < ActiveRecord::Base
belongs_to :user
belongs_to :role
# Authorization plugin
acts_as_authorizable
end

Glenn Rempe

unread,
Aug 19, 2009, 1:43:36 AM8/19/09
to Rails Authorization Plugin
No. Check out the readme and the fully functional test rails app.
You should only need to declare:

acts_as_authorized_user
acts_as_authorizable

In your User model.

See the following:

http://github.com/grempe/rails-authorization-plugin-test/tree/master
http://github.com/DocSavage/rails-authorization-plugin/blob/09ce50e2f35e7fd74f5298ca9f99aca7ab770acc/README.rdoc

Cheers.

Glenn
Reply all
Reply to author
Forward
0 new messages