Athorization on controllers without model #942

Closed
forever-sumit opened this Issue Sep 24, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@forever-sumit

Hi

I have two controllers named AthletesController and CoachesController and both have a same action named "home", and both controller doesn't have models

class AthletesController < ApplicationController
before_filter :authenticate_user!
authorize_resource :class => false

def home
end

def my_coaches
end

def my_videos
end

def view_coach
end
end

class CoachesController < ApplicationController
before_filter :authenticate_user!
authorize_resource :class => false

def home
end
end

and In Ability.rb file I have used this
if user.has_role? :athlete
can :manage, Athlete
elsif user.has_role? :coach
can :manage, Coach
end

I am facing
"uninitialized constant Ability::Coach" and "uninitialized constant Ability::Athlete" error

Do any one have solution for this issue, Please let me know

@graywh

This comment has been minimized.

Show comment
Hide comment
@graywh

graywh Sep 25, 2013

(Re-)read the wiki page: https://github.com/ryanb/cancan/wiki/Non-RESTful-Controllers

If you're going to use :class => false, you should define abilities for :athlete and :coach.

graywh commented Sep 25, 2013

(Re-)read the wiki page: https://github.com/ryanb/cancan/wiki/Non-RESTful-Controllers

If you're going to use :class => false, you should define abilities for :athlete and :coach.

@alex-ross

This comment has been minimized.

Show comment
Hide comment
@alex-ross

alex-ross Dec 26, 2013

@forever-sumit Is the problem solved?

@forever-sumit Is the problem solved?

@forever-sumit

This comment has been minimized.

Show comment
Hide comment
@forever-sumit

forever-sumit Dec 26, 2013

yes, its resolved.

Regards,
Sumit

On Thu, Dec 26, 2013 at 10:55 PM, Alexander Ross
notifications@github.comwrote:

@forever-sumit https://github.com/forever-sumit Is the problem solved?


Reply to this email directly or view it on GitHubhttps://github.com/ryanb/cancan/issues/942#issuecomment-31228216
.

yes, its resolved.

Regards,
Sumit

On Thu, Dec 26, 2013 at 10:55 PM, Alexander Ross
notifications@github.comwrote:

@forever-sumit https://github.com/forever-sumit Is the problem solved?


Reply to this email directly or view it on GitHubhttps://github.com/ryanb/cancan/issues/942#issuecomment-31228216
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment