Ruby on rails rails 3的can能力
我正在使用can gem来限制基于角色的用户 产品没有模型Ruby on rails rails 3的can能力,ruby-on-rails,ruby-on-rails-3,authorization,cancan,Ruby On Rails,Ruby On Rails 3,Authorization,Cancan,我正在使用can gem来限制基于角色的用户 产品没有模型 class ProductsController < ApplicationController authorize_resource :class => false def index @customers=Customer.all end end 但是当我这样写的时候 can [:index], :products 它不允许我访问产品控制器 我的疑问是控制器的名称是产品,但在能力方面我
class ProductsController < ApplicationController
authorize_resource :class => false
def index
@customers=Customer.all
end
end
但是当我这样写的时候
can [:index], :products
它不允许我访问产品控制器
我的疑问是控制器的名称是产品,但在能力方面我们为什么需要编写产品
还有在ability.rb中写复数的可能性
提前感谢当您有一个没有相应型号的控制器时,这将在Cancan aka进行记录,文档示例显示:
class ToolsController < ApplicationController
authorize_resource :class => false
def show
# automatically calls authorize!(:show, :tool) # Note the singular :tool
end
end
你可以阅读更多关于这个的内容
class ToolsController < ApplicationController
authorize_resource :class => false
def show
# automatically calls authorize!(:show, :tool) # Note the singular :tool
end
end
can :index, :product