Skip to content

Loading…

Athorization on controllers without model #942

Open
forever-sumit opened this Issue · 3 comments

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

(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

@forever-sumit Is the problem solved?

@forever-sumit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.