2009-12-31 15:28:48 -05:00
|
|
|
require "rails"
|
2010-02-25 19:48:36 -05:00
|
|
|
require "action_controller"
|
2010-03-26 13:47:55 -04:00
|
|
|
require "action_dispatch/railtie"
|
2010-02-04 12:29:18 -05:00
|
|
|
require "action_view/railtie"
|
2010-02-25 18:05:10 -05:00
|
|
|
require "active_support/core_ext/class/subclasses"
|
2010-02-26 20:31:32 -05:00
|
|
|
require "active_support/deprecation/proxy_wrappers"
|
2010-03-04 14:58:30 -05:00
|
|
|
require "active_support/deprecation"
|
2009-12-31 14:46:56 -05:00
|
|
|
|
2010-03-26 13:47:55 -04:00
|
|
|
require "action_controller/railties/log_subscriber"
|
|
|
|
require "action_controller/railties/url_helpers"
|
|
|
|
|
2009-12-23 17:55:12 -05:00
|
|
|
module ActionController
|
2009-12-31 16:11:54 -05:00
|
|
|
class Railtie < Rails::Railtie
|
2010-03-26 13:47:55 -04:00
|
|
|
config.action_controller = ActiveSupport::OrderedOptions.new
|
2010-02-25 19:48:36 -05:00
|
|
|
|
2010-03-04 14:58:30 -05:00
|
|
|
ad = config.action_dispatch
|
|
|
|
config.action_controller.singleton_class.send(:define_method, :session) do
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session has been " \
|
|
|
|
"renamed to config.action_dispatch.session.", caller
|
|
|
|
ad.session
|
|
|
|
end
|
2010-01-12 18:41:04 -05:00
|
|
|
|
2010-03-04 14:58:30 -05:00
|
|
|
config.action_controller.singleton_class.send(:define_method, :session=) do |val|
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session has been " \
|
|
|
|
"renamed to config.action_dispatch.session.", caller
|
|
|
|
ad.session = val
|
|
|
|
end
|
2010-03-04 00:16:35 -05:00
|
|
|
|
2010-03-04 14:58:30 -05:00
|
|
|
config.action_controller.singleton_class.send(:define_method, :session_store) do
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session_store has been " \
|
|
|
|
"renamed to config.action_dispatch.session_store.", caller
|
|
|
|
ad.session_store
|
2010-01-24 19:06:12 -05:00
|
|
|
end
|
|
|
|
|
2010-03-04 14:58:30 -05:00
|
|
|
config.action_controller.singleton_class.send(:define_method, :session_store=) do |val|
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session_store has been " \
|
|
|
|
"renamed to config.action_dispatch.session_store.", caller
|
|
|
|
ad.session_store = val
|
|
|
|
end
|
2010-03-03 20:36:08 -05:00
|
|
|
|
2010-03-26 13:47:55 -04:00
|
|
|
log_subscriber :action_controller, ActionController::Railties::LogSubscriber.new
|
2010-03-04 14:58:30 -05:00
|
|
|
|
|
|
|
initializer "action_controller.logger" do
|
2010-03-07 09:24:30 -05:00
|
|
|
ActionController.base_hook { self.logger ||= Rails.logger }
|
2010-03-04 14:58:30 -05:00
|
|
|
end
|
2010-03-03 20:36:08 -05:00
|
|
|
|
2009-12-23 17:55:12 -05:00
|
|
|
initializer "action_controller.set_configs" do |app|
|
2010-03-03 20:36:08 -05:00
|
|
|
paths = app.config.paths
|
|
|
|
ac = app.config.action_controller
|
2010-03-08 17:02:41 -05:00
|
|
|
|
|
|
|
ac.assets_dir = paths.public.to_a.first
|
2010-03-04 14:58:30 -05:00
|
|
|
ac.javascripts_dir = paths.public.javascripts.to_a.first
|
|
|
|
ac.stylesheets_dir = paths.public.stylesheets.to_a.first
|
2010-03-08 17:02:41 -05:00
|
|
|
ac.secret = app.config.cookie_secret
|
2010-03-03 20:36:08 -05:00
|
|
|
|
2010-03-19 14:09:41 -04:00
|
|
|
ActionController.base_hook do
|
|
|
|
self.config.merge!(ac)
|
|
|
|
end
|
2009-12-23 17:55:12 -05:00
|
|
|
end
|
|
|
|
|
2009-12-23 20:01:07 -05:00
|
|
|
initializer "action_controller.initialize_framework_caches" do
|
2010-03-07 09:24:30 -05:00
|
|
|
ActionController.base_hook { self.cache_store ||= RAILS_CACHE }
|
2009-12-23 20:01:07 -05:00
|
|
|
end
|
2010-01-26 15:05:50 -05:00
|
|
|
|
|
|
|
initializer "action_controller.set_helpers_path" do |app|
|
2010-03-07 09:24:30 -05:00
|
|
|
ActionController.base_hook do
|
|
|
|
self.helpers_path = app.config.paths.app.helpers.to_a
|
|
|
|
end
|
2010-01-26 15:05:50 -05:00
|
|
|
end
|
2010-02-25 19:48:36 -05:00
|
|
|
|
|
|
|
initializer "action_controller.url_helpers" do |app|
|
2010-03-07 09:24:30 -05:00
|
|
|
ActionController.base_hook do
|
2010-03-26 13:47:55 -04:00
|
|
|
extend ::ActionController::Railties::UrlHelpers.with(app.routes)
|
2010-03-07 09:24:30 -05:00
|
|
|
end
|
2010-02-26 20:31:32 -05:00
|
|
|
|
|
|
|
message = "ActionController::Routing::Routes is deprecated. " \
|
|
|
|
"Instead, use Rails.application.routes"
|
|
|
|
|
|
|
|
proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(app.routes, message)
|
|
|
|
ActionController::Routing::Routes = proxy
|
2010-02-25 19:48:36 -05:00
|
|
|
end
|
2009-12-23 17:55:12 -05:00
|
|
|
end
|
2010-02-25 19:48:36 -05:00
|
|
|
end
|