Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

SF Standup 8/12/2011: Helpers All The Way Down

Ken Mayer
Friday, August 12, 2011

Ask for Help

“clear_helpers and ActionController::Base”

A [recent?] change to Rails 3 moved helper :all from the default ApplicationController to ActionController::Base — which would be fine, except that there’s little documentation on how to override this (for example, when you don’t want all helpers included in your controller class)

There is a lesser known method from AbstractController::Helpers

# Clears up all existing helpers in this class, only keeping the helper
# with the same name as this class.
def clear_helpers

You would think that since helper :all is being called from the base class, there would be no way to override it. Except for this little bit of code at the bottom of ActionController::Base:

def self.inherited(klass)
  super
  klass.helper :all if klass.superclass == ActionController::Base
end

So, clear_helpers will “work” for all subclasses of ApplicationController — which is everything you should care about. And the default, all helpers included, remains.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Add New Comment Cancel reply

Your email address will not be published.

Ken Mayer

Ken Mayer
San Francisco

Recent Posts

  • Sencha Touch BDD – Part 5 – Controller Testing
  • Sencha Touch BDD – Part 4 – PhantomJS
  • Sencha Touch BDD – Part 3 – Testing Views and Mocking Stores
Subscribe to Ken's Feed

Author Topics

bdd (5)
bloggerdome (5)
jasmine (6)
javascript (5)
mobile (6)
sencha (5)
meta programming (1)
refactoring (1)
ruby (1)
agile (18)
planning (1)
design (2)
heroku (3)
rails (8)
workflow (5)
cucumber (3)
testing (4)
performance (3)
devops (1)
jquery (2)
careers (1)
college job fairs (1)
hiring (1)
jobs (1)
recruitment (1)
bundler (3)
facebook (1)
json (1)
nginx (1)
movember (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >