Cancan authentication with Rails -
i have complex scenario authentication it, came model structure.
can 1 guide how use cancan embed authentication structure.
def initialize (user) user ||= user.new # guest user user.roles.each |role| role.permissions.each |p| can :read, p.resource.class_name.to_s.classify.constantize |subject| p.resource.class_name == subject.id , p.can_read end can :create, p.resource.class_name.to_s.classify.constantize |subject| p.resource.class_name == subject.id , p.can_create end can :update, p.resource.class_name.to_s.classify.constantize |subject| p.resource.class_name == subject.id , p.can_update end can :destroy, p.resource.class_name.to_s.classify.constantize |subject| p.resource.class_name == subject.id , p.can_delete end end end end
Comments
Post a Comment