module Footnotes class Railtie < ::Rails::Railtie config.before_configuration do if ::Rails.env.development? require 'rails-footnotes/footnotes' require 'rails-footnotes/backtracer' require 'rails-footnotes/view_subscriber' # Require each individual note notes_glob = File.expand_path("../rails-footnotes/notes/*.rb", __FILE__) Dir[notes_glob].each{|note| require note } # Subscribe to view events so we can use them later ActiveSupport::LogSubscriber.attach_to(:action_view, Footnotes.view_subscriber) # The footnotes are applied by default to all actions. To remove the # footnotes from an action, use skip_filter in your controller. ActionController::Base.prepend_before_filter Footnotes::BeforeFilter ActionController::Base.after_filter Footnotes::AfterFilter end end # Hook into the logger so we can collect logs initializer "rails3-footnotes.hook_logger" do if ::Rails.env.development? raise ArgumentError, "The logs footnote requires a logger" unless Rails.logger Rails.logger.extend LoggingExtensions end end end end