Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9222671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:53:16+00:00 2026-06-18T03:53:16+00:00

I have a Ruby on Rails Controller with a before_filter using a custom class:

  • 0

I have a Ruby on Rails Controller with a before_filter using a custom class:

class ApplicationController
  before_filter CustomBeforeFilter      
end

I have another controller inherited from ApplicationController, where I would like to skip the CustomBeforeFilter:

class AnotherController < ApplicationController
  skip_before_filter CustomBeforeFilter
end

That doesn’t work. The before_filter is still executed.

How can I skip a Ruby on Rails before filter that uses a custom class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:53:17+00:00Added an answer on June 18, 2026 at 3:53 am

    Class callbacks are assigned a random callback name when they are added to the filter chain. The only way I can think of to do this is to find the name of callback first:

    skip_before_filter _process_action_callbacks.detect {|c| c.raw_filter == CustomBeforeFilter }.filter
    

    If you want something a little cleaner in your controllers, you could override the skip_before_filter method in ApplicationController and make it available to all controllers:

    class ApplicationController < ActionController::Base
      def self.skip_before_filter(*names, &block)
        names = names.map { |name|
          if name.class == Class
            _process_action_callbacks.detect {|callback| callback.raw_filter == name }.filter
          else
            name
          end
        }
    
        super
      end
    end
    

    Then you could do:

    class AnotherController < ApplicationController
      skip_before_filter CustomBeforeFilter
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Ruby on Rails, I would like to add a before_filter to every controller
I have a Ruby on Rails page that loads another page using jquery. I
In Ruby on Rails, I have an update method in a controller, that is
I have a ruby on rails application and it would be nice to see
I am using Devise with Ruby on Rails. I have a few pages that
I am using Ruby on Rails 3.2.2 and I would like to run some
I am using Ruby on Rails 3.2.2 and I would like to know if
In my Ruby on Rails app I have set up OAuth to work using
I am using ruby 1.9.2-p180, rails 3.0.7. I have used validates_acceptance_of since the user
I have a Ruby On Rails 3.x application using device. My goal is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.