- My admin
can :manage, Widget
- My user
can :manage, Widget, :user_id => user.id
- In my view, I want to show a link only开发者_开发知识库 if the current_user can manage each and every Widget record.
In general?
can? :manage, Widget
If you're referring to some check on existing records, that sounds like a design flaw, but this should work. Note that if this is the approach you're taking, you have a race condition with other Widget
records being created after you make this check.
(can? :manage, Widget) || (Widget.count == Widget.count(:conditions => ["user_id == ?", current_user.id]))
精彩评论