Sha256: 15d49750753524fe81450f7f16e1f88dfc058c9ff486d2139449d5fb9d7d99a6

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'ajax/action_controller'
require 'ajax/action_view'

module Ajax
  class Railtie < Rails::Railtie
    rake_tasks do
      load(File.expand_path('../../../tasks/ajax_tasks.rake', __FILE__))
    end

    initializer 'ajax.action_integration' do
      ActiveSupport.on_load :action_view do
        include Ajax::ActionView

        self.class_eval do
          unless instance_methods.include?('_render_layout_with_tracking')
            def _render_layout_with_tracking(layout, locals, &block)
              controller.instance_variable_set(:@_rendered_layout, layout)
              _render_layout_without_tracking(layout, locals, &block)
            end
            alias_method_chain :_render_layout, :tracking
          end
        end
      end
      ActiveSupport.on_load :action_controller do
        include Ajax::ActionController
      end
    end

    initializer "ajax.middleware" do |app|
      app.config.middleware.insert_before "ActionDispatch::Head", "Rack::Ajax"
    end

    initializer 'ajax.routes' do |app|
      app.routes_reloader.paths << Ajax.root + 'rails/routes.rb'
    end

    initializer 'ajax.logger' do |app|
      Ajax.logger = ::Rails.logger
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ajax-1.1.7 lib/ajax/railtie.rb