I think you need to use
has_any_role?
Which takes two or more arguments as characters. But your cf_content method returns an array. If the user needs 3 roles that you defined in cf_create , you need to do something more like
def create cf_content.all? { |role| user.has_role?(role) } end
UPDATE:
If you need only one role than a simple change:
def create cf_content.any? { |role| user.has_role?(role) } end
Also, I'm not sure what they represent, but if they are the names of your roles, I would suggest using lowercase letters. Therefore, instead of
[ :Admin, :CF_Author, :CF_Editor ]
You can use:
[: admin ,: cf_author ,: cf_editor]
UPDATE 2:
Originally? will not accept an array. So if you want to check has_role? on an array do you need to iterate has_role? over each element of the array. Since the: cf_content method returns an array of roles, change from:
def create user.has_role? :cf_content end
To:
def create :cf_content.any? { |role| user.has_role?(role) } end
But you did not explain where you are trying to put your "content policy".
source share