Created
September 22, 2011 11:14
-
-
Save paneq/1234553 to your computer and use it in GitHub Desktop.
skip loading all helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SkipAutoloadingAllHelpersController < ActionController::Base | |
# Fuck you, rails! | |
def self.helper(*params) | |
if params.include?(:all) | |
Rails.logger.warn("Rejected :all") | |
params.reject!{|p| p == :all} | |
end | |
super | |
end | |
def self.default_helper_module! | |
end | |
clear_helpers # http://stackoverflow.com/questions/1179865/why-are-all-rails-helpers-available-to-all-views-all-the-time-is-there-a-way-to | |
end | |
class ApplicationController < SkipAutoloadingAllHelpersController | |
protect_from_forgery | |
layout 'application' | |
helper :application # not loaded automatically because we turned it off | |
end | |
module MssHelper | |
def tabs | |
[ Tab.new("Absences", mss_absence_path) ] | |
end | |
def current_tab | |
nil | |
end | |
end | |
module Mss::AbsenceHelper | |
def current_tab | |
tabs.first | |
end | |
end | |
class Mss::AbsenceController < ApplicationController | |
helper :mss | |
helper :"mss/absence" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment