Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Archive for the ‘documentation’ Category

Rails: Skipping Base Class Filters in Subclasses

with 3 comments

I encountered a case where we needed to skip a filter as it was causing infinite redirection in a subclass. I found my answer in: Rails Filters Documentation

Filter chain skipping

Declaring a filter on a base class conveniently applies to its subclasses, but sometimes a subclass should skip some of its superclass’ filters:

  class ApplicationController < ActionController::Base
    before_filter :authenticate
    around_filter :catch_exceptions

  class WeblogController < ApplicationController
    # Will run the :authenticate and :catch_exceptions filters.

  class SignupController < ApplicationController
    # Skip :authenticate, run :catch_exceptions.
    skip_before_filter :authenticate

  class ProjectsController < ApplicationController
    # Skip :catch_exceptions, run :authenticate.
    skip_filter :catch_exceptions

  class ClientsController  :index

Written by imsaar

November 10, 2009 at 9:07 pm

Posted in code, documentation, rails, ruby