I'm using cancan in my rails 3 application with mysql DB.
When i create a rule based on an enum column i always get AccessDenied only for "show" action. Any idea why? I use enumerated_attribute to enforce enums in the models and an actual ENUM type column in the database.
Example: I have a Post that has an enum field privacy with ['PUBLIC','PRIVATE','LOCAL']. I always get AccessDenied when i use this rule:开发者_运维知识库
can :read, Post, :privacy => 'PUBLIC'
Every other rule works perfectly. The above rule also works great on "index" action.
UPDATE 1:
My ability.rb:
class Ability
include CanCan::Ability
def initialize(user)
can :read, Post, :privacy => 'PUBLIC'
end
end
The question was answered here: https://github.com/ryanb/cancan/issues/479
精彩评论