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-04-22 06:00:13 -04:00
|
|
|
config.action_controller.singleton_class.tap do |d|
|
|
|
|
d.send(:define_method, :session) do
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session has been deprecated. " <<
|
|
|
|
"Please use Rails.application.config.session_store instead.", caller
|
|
|
|
end
|
2010-01-12 18:41:04 -05:00
|
|
|
|
2010-04-22 06:00:13 -04:00
|
|
|
d.send(:define_method, :session=) do |val|
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session= has been deprecated. " <<
|
|
|
|
"Please use config.session_store(name, options) instead.", caller
|
|
|
|
end
|
2010-03-04 00:16:35 -05:00
|
|
|
|
2010-04-22 06:00:13 -04:00
|
|
|
d.send(:define_method, :session_store) do
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session_store has been deprecated. " <<
|
|
|
|
"Please use Rails.application.config.session_store instead.", caller
|
|
|
|
end
|
2010-01-24 19:06:12 -05:00
|
|
|
|
2010-04-22 06:00:13 -04:00
|
|
|
d.send(:define_method, :session_store=) do |val|
|
|
|
|
ActiveSupport::Deprecation.warn "config.action_controller.session_store= has been deprecated. " <<
|
|
|
|
"Please use config.session_store(name, options) instead.", caller
|
|
|
|
end
|
2010-03-04 14:58:30 -05:00
|
|
|
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
|
|
|
|
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
|
|
|
|
2010-04-22 06:00:13 -04:00
|
|
|
ac.assets_dir ||= paths.public.to_a.first
|
|
|
|
ac.javascripts_dir ||= paths.public.javascripts.to_a.first
|
|
|
|
ac.stylesheets_dir ||= paths.public.stylesheets.to_a.first
|
|
|
|
ac.page_cache_directory ||= paths.public.to_a.first
|
|
|
|
ac.helpers_path ||= paths.app.helpers.to_a
|
2010-03-03 20:36:08 -05:00
|
|
|
|
2010-03-29 20:08:08 -04:00
|
|
|
ActiveSupport.on_load(:action_controller) do
|
2010-03-19 14:09:41 -04:00
|
|
|
self.config.merge!(ac)
|
|
|
|
end
|
2009-12-23 17:55:12 -05:00
|
|
|
end
|
|
|
|
|
2010-04-22 06:00:13 -04:00
|
|
|
initializer "action_controller.logger" do
|
|
|
|
ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
|
2009-12-23 20:01:07 -05:00
|
|
|
end
|
2010-01-26 15:05:50 -05:00
|
|
|
|
2010-04-22 06:00:13 -04:00
|
|
|
initializer "action_controller.initialize_framework_caches" do
|
|
|
|
ActiveSupport.on_load(:action_controller) { self.cache_store ||= RAILS_CACHE }
|
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-29 20:08:08 -04:00
|
|
|
ActiveSupport.on_load(:action_controller) 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
|