跳过使用块定义的before_filter [英] Skip before_filter defined with block

查看:112
本文介绍了跳过使用块定义的before_filter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用块定义before_filter时,是否可以使用 skip_before_filter 跳过before过滤器。例如:

Is it possible to skip a before filter in using skip_before_filter when the before_filter is defined with a block. For example:

class ApplicationController < ActionController::Base
  before_filter do |controller|
    # filter stuff
  end
end

我知道,是否可以使用常规方式通过方法名称定义过滤器?

I know, that is it possible using the "normal" way of defining the filter with a method name.

推荐答案

这绝对不可能。从文档中:

Its most definitely not possible. From the documentation:


请注意,跳过使用Ruby相等,因此无法跳过使用#skip_filter的匿名proc定义的回调。 p>

Note that skipping uses Ruby equality, so it’s impossible to skip a callback defined using an anonymous proc using #skip_filter

http://apidock.com/rails/AbstractController/Callbacks/ClassMethods/skip_action_callback

这篇关于跳过使用块定义的before_filter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆