【发布时间】:2015-02-02 05:24:11
【问题描述】:
1. skip_before_filter :authorize, :only => [:index,:show], :if => proc {|c| request.json?}
2. skip_before_filter :authorize, :only => [:index,:show], :if => :format_json?
def format_json?
request.format.json?
end
3. skip_before_filter :authorize, :only => [:index, :show] , :if =>request.content_type == "json"
for the first request it is showing:
#undefined local variable or method `request' for ExamsController:Class
If i refresh the page it is not skipping anyting
仅当请求内容为 json 时,我才想跳过“索引”和“显示”操作的身份验证。我已经尝试了上述示例,但没有任何效果。任何建议都会有所帮助。
【问题讨论】:
标签: ruby-on-rails json authentication ruby-on-rails-3.2