I'm using Rails 4, Devise, Role Model and CanCanCan to make an app.
I am trying to define abilities in my ability.rb.
I am trying the following:
can :read, Project, {:active => true, :closed => false && Project.sweep.disclosure.allusers => true}
However, I am getting a syntax error on the above line that says:
syntax error, unexpected =>, expecting '}'
...ct.sweep.disclosure.allusers => true}
I have tried replacing the => with :true and I get a syntax error in that case which says:
syntax error, unexpected tSYMBEG, expecting '}'
...ect.sweep.disclosure.allusers :true}
I have also tried putting the colon before the start of the attribute, in which case I get this error:
syntax error, unexpected =>, expecting '}'
...ct.sweep.disclosure.allusers => true}
I can't think of any more ways to try this.
The relevant attribute I'm trying to test is in a model called Disclosure.rb. That model belongs to a model called Sweep.rb. Sweep belongs to a model called Project.rb.
I can't figure out how to define abilities and these errors have exhausted me. Does anyone know how to use CanCanCan to define abilities and if so, please can you see what I've done wrong in defining the attributes that determine whether this user can see these Projects?
as discussed in the comments you should use something like
{:active => true, :closed => false, :sweep => { :disclosure => { :allusers => true } } }