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-08-02 11:38:44 -04:00
|
|
|
require "abstract_controller/railties/routes_helpers"
|
2012-03-15 03:48:38 -04:00
|
|
|
require "action_controller/railties/helpers"
|
2009-12-31 14:46:56 -05:00
|
|
|
|
2009-12-23 17:55:12 -05:00
|
|
|
module ActionController
|
2012-02-29 13:44:45 -05:00
|
|
|
class Railtie < Rails::Railtie #:nodoc:
|
2010-03-26 13:47:55 -04:00
|
|
|
config.action_controller = ActiveSupport::OrderedOptions.new
|
2010-02-25 19:48:36 -05:00
|
|
|
|
2012-01-10 13:33:26 -05:00
|
|
|
initializer "action_controller.assets_config", :group => :all do |app|
|
|
|
|
app.config.action_controller.assets_dir ||= app.config.paths["public"].first
|
|
|
|
end
|
|
|
|
|
2012-03-15 03:48:38 -04:00
|
|
|
initializer "action_controller.set_helpers_path" do |app|
|
|
|
|
ActionController::Helpers.helpers_path = app.helpers_paths
|
|
|
|
end
|
|
|
|
|
2010-07-23 18:48:12 -04:00
|
|
|
initializer "action_controller.set_configs" do |app|
|
2010-08-23 12:31:29 -04:00
|
|
|
paths = app.config.paths
|
|
|
|
options = app.config.action_controller
|
|
|
|
|
2012-03-15 03:48:38 -04:00
|
|
|
options.logger ||= Rails.logger
|
|
|
|
options.cache_store ||= Rails.cache
|
|
|
|
|
2010-10-06 11:18:59 -04:00
|
|
|
options.javascripts_dir ||= paths["public/javascripts"].first
|
|
|
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
|
|
|
options.page_cache_directory ||= paths["public"].first
|
2010-08-23 12:31:29 -04:00
|
|
|
|
2012-03-15 03:48:38 -04:00
|
|
|
# Ensure readers methods get compiled
|
2010-12-09 07:40:45 -05:00
|
|
|
options.asset_path ||= app.config.asset_path
|
|
|
|
options.asset_host ||= app.config.asset_host
|
2011-12-12 10:52:56 -05:00
|
|
|
options.relative_url_root ||= app.config.relative_url_root
|
2010-09-27 08:50:39 -04:00
|
|
|
|
2010-03-29 20:08:08 -04:00
|
|
|
ActiveSupport.on_load(:action_controller) do
|
2010-09-06 14:47:25 -04:00
|
|
|
include app.routes.mounted_helpers
|
2010-08-06 10:34:48 -04:00
|
|
|
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
|
2012-03-15 03:48:38 -04:00
|
|
|
extend ::ActionController::Railties::Helpers
|
|
|
|
|
2012-03-13 15:21:41 -04:00
|
|
|
options.each do |k,v|
|
|
|
|
k = "#{k}="
|
|
|
|
if respond_to?(k)
|
|
|
|
send(k, v)
|
|
|
|
elsif !Base.respond_to?(k)
|
|
|
|
raise "Invalid option key: #{k}"
|
|
|
|
end
|
|
|
|
end
|
2010-03-07 09:24:30 -05:00
|
|
|
end
|
2010-07-23 18:48:12 -04:00
|
|
|
end
|
2010-09-27 08:50:39 -04:00
|
|
|
|
2010-09-27 14:42:02 -04:00
|
|
|
initializer "action_controller.compile_config_methods" do
|
2010-09-27 08:50:39 -04:00
|
|
|
ActiveSupport.on_load(:action_controller) do
|
2010-09-27 14:42:02 -04:00
|
|
|
config.compile_methods! if config.respond_to?(:compile_methods!)
|
2010-09-27 08:50:39 -04:00
|
|
|
end
|
|
|
|
end
|
2009-12-23 17:55:12 -05:00
|
|
|
end
|
2010-07-18 13:49:51 -04:00
|
|
|
end
|