aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-16 19:14:06 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-16 19:14:20 +0100
commit8e236152457ed48bb436e9bffb4c5d6d4b6a26d4 (patch)
tree8399705099848741f225d1c71916438717bc82b0 /railties/lib
parentd0d25a9317aaea794f30e067e9388fe4e08bcde5 (diff)
downloadrails-8e236152457ed48bb436e9bffb4c5d6d4b6a26d4.tar.gz
rails-8e236152457ed48bb436e9bffb4c5d6d4b6a26d4.tar.bz2
rails-8e236152457ed48bb436e9bffb4c5d6d4b6a26d4.zip
Use lazy load hooks to set parameter wrapping configuration. This means that it doesn't force Action Controller / Active Record to load, but it doesn't fail if they have already loaded. Thanks @josevalim for the hint.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt16
1 files changed, 9 insertions, 7 deletions
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
index b7b344a62d..d640f578da 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
@@ -3,12 +3,14 @@
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
-<%= app_const %>.configure do
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
- config.action_controller.wrap_parameters = { <%= key_value :format, "[:json]" %> }
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters <%= key_value :format, "[:json]" %>
+end
- <%- unless options.skip_active_record? -%>
- # Disable root element in JSON by default.
- config.active_record.include_root_in_json = false
- <%- end -%>
+<%- unless options.skip_active_record? -%>
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+ self.include_root_in_json = false
end
+<%- end -%>