跳过在设计中授权资源

时间:2014-07-27 00:53:30

标签: ruby-on-rails authentication devise authorization

我尝试在我正在处理的项目中创建用户个人资料,因此我尝试将skip_authorize_resource :only => [:show]添加到用户控制器和用户模型。但是,当我访问/users/1时,没有任何反应,当我将其添加到控制器时,我提示登录;当我将它添加到模型时,我收到一条错误消息:

undefined method `skip_authorize_resource' 

1 个答案:

答案 0 :(得分:0)

我认为您可以使用authenticate_user方法进行设计

skip_before_filter :authenticate_user!, :only => :show

或者您可以使用

 check_authorization 

控制器中的方法

像这样

class ApplicationController < ActionController::Base
  check_authorization :unless => :do_not_check_authorization?

   private
   def do_not_check_authorization?
     ...
   end
 end