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-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"
|
2013-12-22 16:54:51 -05:00
|
|
|
require "action_view/railtie"
|
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-08-01 14:54:22 -04:00
|
|
|
config.eager_load_namespaces << ActionController
|
|
|
|
|
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
|
|
|
|
|
2012-08-30 17:36:59 -04:00
|
|
|
initializer "action_controller.parameters_config" do |app|
|
2013-01-19 12:32:27 -05:00
|
|
|
options = app.config.action_controller
|
|
|
|
|
|
|
|
ActionController::Parameters.permit_all_parameters = options.delete(:permit_all_parameters) { false }
|
2014-06-27 02:01:30 -04:00
|
|
|
if app.config.action_controller[:always_permitted_parameters]
|
|
|
|
ActionController::Parameters.always_permitted_parameters =
|
|
|
|
app.config.action_controller.delete(:always_permitted_parameters)
|
|
|
|
end
|
2013-01-19 12:32:27 -05:00
|
|
|
ActionController::Parameters.action_on_unpermitted_parameters = options.delete(:action_on_unpermitted_parameters) do
|
|
|
|
(Rails.env.test? || Rails.env.development?) ? :log : false
|
|
|
|
end
|
2012-08-30 17:36:59 -04:00
|
|
|
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
|
|
|
|
|
2013-01-19 12:32:27 -05:00
|
|
|
options.logger ||= Rails.logger
|
|
|
|
options.cache_store ||= Rails.cache
|
2012-03-15 03:48:38 -04:00
|
|
|
|
2013-01-19 12:32:27 -05:00
|
|
|
options.javascripts_dir ||= paths["public/javascripts"].first
|
|
|
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
2010-08-23 12:31:29 -04:00
|
|
|
|
2012-03-15 03:48:38 -04:00
|
|
|
# Ensure readers methods get compiled
|
2013-01-19 12:32:27 -05:00
|
|
|
options.asset_host ||= app.config.asset_host
|
|
|
|
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
|