Can Can with Role Model restriction
NickName:Mini John Ask DateTime:2013-12-02T17:10:03

Can Can with Role Model restriction

I'm Trying to achieve that the user can see only HIS applications, and not the "Application Index" containing all the applications from all Users.

My Header:

 <%= link_to "My Application ", current_user.application %>

My Abilities:

 if user.has_role? :speaker
  can :read, Application do |application| # heres the problem
    application.try(:user) == user
  end
  can :create, Application
  can :update, Application do |application|
    application.try(:user) == user
  end
end

Currently the User can access the Application/Index page. But the restriction should give him only access to:

http://localhost:3000/applications/8 # 8 being his application

What am i missing ?

Copyright Notice:Content Author:「Mini John」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20324495/can-can-with-role-model-restriction

More about “Can Can with Role Model restriction” related questions

Can Can with Role Model restriction

I'm Trying to achieve that the user can see only HIS applications, and not the "Application Index" containing all the applications from all Users. My Header: &lt;%= link_to "My Application ",

Show Detail

RDFS/OWL Model Restriction

I am going through some questions on RDFS/OWL models, and have to infer some triples based on a model. However, I haven't seen the restriction in this model, at least a restriction written like thi...

Show Detail

Can an named restriction exist in OWL?

Can we define a restriction as a named class? I mean, instead of using this: :myclass owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty :hasAge ; owl:

Show Detail

Add restriction to model

Given these two models: models.py PRIMARY, SECONDARY = 0, 1 STORAGE_TYPE = ( (PRIMARY, "Primary"), (SECONDARY, "Secondary"), ) class Storage(models.Model): company = models.For

Show Detail

How I can make the restriction?

I'm new to the world cp optimizer and this starting to make small tests. I have the following question and I need your help, please. This is my code: Data const IloInt nbPair = 6; const IloInt

Show Detail

Why Select Query by Restriction Not IN cannot execute normally, but by Restriction IN can?

I try to select some material data from one Table, and have one restriction, that the material should not exists in one View. So, below is my code. It cannot be executed normally. select * from T...

Show Detail

Can XSD restriction be platform specific?

I have to specify a restriction for one of xml attribute, I know I can use the syntax below. But the minInclusive and MaxInclusive depends on pl...

Show Detail

Can I add a attribute and a restriction to a xsd type inline?

I need to imply a restriction and an attribute on a type. I know it can be done this way &lt;xs:simpleType name="Name"&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:minLength valu..

Show Detail

Can owl:class and owl:restriction be removed from restriction class definitions?

Are these statements the same ? Is there any concern if I remove owl:Restriction and owl:Class. they seem redundant to state, but this is always how I see examples online. owl:onProperty has do...

Show Detail

Are there restriction which HiveQL can but SQL can't?

I plan to migrate to SQL from HiveQL, but I have no idea about the restriction or care point between the two language. I know there are some restriction from SQL to HiveQL. For example, 1:SQL can s...

Show Detail