I use cancancan
gem for role based authorization rules. I need to preform something like:
can :read, Post, Post.status = 1
This means that user can read post with status = 1. How can i do that?
I use cancancan
gem for role based authorization rules. I need to preform something like:
can :read, Post, Post.status = 1
This means that user can read post with status = 1. How can i do that?
According to the docs it should be as simple as
can :read, Post, status: 1
You must use database columns for these conditions (i.e. make sure status
is a column in the posts
table).
If this is not the case or you need something more complex than a hash of conditions, you can look into Defining Abilities with Blocks
Hope this helps.
Try
can(:read, Post, status: 1)