aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/railtie.rb
blob: 07c6b8f2b626dbaf08c7579a1326d5cbe94ec3dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require "rails"
require "action_controller"
require "action_view/railtie"
require "active_support/core_ext/class/subclasses"
require "active_support/deprecation/proxy_wrappers"

module ActionController
  class Railtie < Rails::Railtie
    railtie_name :action_controller

    require "action_controller/railties/log_subscriber"
    require "action_controller/railties/url_helpers"

    log_subscriber ActionController::Railties::LogSubscriber.new

    initializer "action_controller.logger" do
      ActionController::Base.logger ||= Rails.logger
    end

    initializer "action_controller.set_configs" do |app|
      app.config.action_controller.each do |k,v|
        ActionController::Base.send "#{k}=", v
      end
    end

    initializer "action_controller.initialize_framework_caches" do
      ActionController::Base.cache_store ||= RAILS_CACHE
    end

    initializer "action_controller.set_helpers_path" do |app|
      ActionController::Base.helpers_path = app.config.paths.app.helpers.to_a
    end

    initializer "action_controller.url_helpers" do |app|
      ActionController::Base.extend ::ActionController::Railtie::UrlHelpers.with(app.routes)

      message = "ActionController::Routing::Routes is deprecated. " \
                "Instead, use Rails.application.routes"

      proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(app.routes, message)
      ActionController::Routing::Routes = proxy
    end
  end
end