rails 3 can can ability
NickName:Siva KB Ask DateTime:2014-09-08T17:53:10

rails 3 can can ability

I am using can can gem to restriction user based on role there is no model for product

class ProductsController < ApplicationController
    authorize_resource :class => false

   def index
     @customers=Customer.all
   end
end

in ability.rb

when i write like this can can allow me to acess the product controller

can [:index], :product

but when i write like this

can [:index], :products

it doesnot allow me to acess the product controller

my doubt is the controller name is products but in ability why we need to write product
and it's possibility to write plural in ability.rb ?

Thanks in advance

Copyright Notice:Content Author:「Siva KB」,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/25721556/rails-3-can-can-ability

More about “rails 3 can can ability” related questions

rails 3 can can ability

I am using can can gem to restriction user based on role there is no model for product class ProductsController &lt; ApplicationController authorize_resource :class =&gt; false def index ...

Show Detail

Rails3 - CanCan - uninitialized constant Ability::Page

I have just added cancan 1.5.0 to my rails 3 app here is my ability file - def initialize(user) user ||= User.new if user.role == 'Admin' can :manage, :all end if user.role == 'Standard' can :

Show Detail

Rails Can Can Ability Class For Multiple Devise Models

I was wondering how I can define an ability class and serve that ability class depending on the user that has logged in. I am using Active Admin, Can Can and Devise and I have successfully created a

Show Detail

cancancan ability with rails 4.0

I am using cancancan authentication mechanism in my rails application. I want only those users who are owner of their own posts and comments t be edited and deleted , and admin to manage all the th...

Show Detail

Rails Cancancan define ability on 3 association

Using Rails 6 and CanCanCan. Here are my models: class Shop &lt; ApplicationRecord has_many :shop_reviews, dependent: :destroy end class ShopReview &lt; ApplicationRecord belongs_to :shop,

Show Detail

Rails CanCan gem refactoring Ability class

I have a around 13 models in my rails app, I use ability on all of them. My ability class has grown huge. I have different ability conditions on different CRUD actions which is making it hard to ma...

Show Detail

Cancancan ability debugging fails in rails console and Rspec

I have this in models/ability.rb class Ability include CanCan::Ability def initialize(user) user ||= User.new if user.role? :registered can :read Post end end When I..

Show Detail

Rails: Ability and ActiveAdmin not working as expected

I am working on a Ruby on Rails project using ActiveAdmin and Cancancan. I defined some abilities for role users like super_administrator, administrator or subscribers. After writing some units te...

Show Detail

how get action in ability block of cancan gem of ruby on rails?

I install cancan gem in rails app and i have block in my ability.rb like this ... can [:action1,:action2,:action3] ,Obj do |x| # I wante to get current action, like this if action == action1 ...

Show Detail

Can NodeJS run within a Rails 3 app? (to achieve high I/O concurrency)

I am quite intrigued by NodeJS at the moment and really like its ability to run high I/O concurrency. I also read this interesting article related to the subject claiming that Rails 4 will be abl...

Show Detail