Search code examples
ruby-on-railsruby-on-rails-3.2before-filter

Skip before_filter defined with block


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.


Solution

  • Its most definitely not possible. From the documentation:

    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