Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't refer to ActionController::Base in the wrap_parameters initiali…

…zer - use config object instead. Cuts about 15% off the load time. (#734)
  • Loading branch information...
commit 6c5f67cac15c43bafcd917c346cccfcf3fa5fb95 1 parent 03a045b
@jonleighton jonleighton authored
View
2  actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -121,6 +121,8 @@ def wrap_parameters(name_or_model_or_options, options = {})
_set_wrapper_defaults(_wrapper_options.slice(:format).merge(options), model)
end
+ alias :wrap_parameters= :wrap_parameters
+
# Sets the default wrapper key or model which will be used to determine
# wrapper key and attribute names. Will be called automatically when the
# module is inherited.
View
7 actionpack/test/controller/params_wrapper_test.rb
@@ -180,6 +180,13 @@ def test_not_wrapping_abstract_model
assert_parameters({ 'username' => 'sikachu', 'title' => 'Developer', 'user' => { 'username' => 'sikachu', 'title' => 'Developer' }})
end
end
+
+ def test_assignment_alias
+ with_default_wrapper_options do
+ UsersController.wrap_parameters = { :format => [:foo] }
+ assert_equal({ :format => [:foo], :name => "user" }, UsersController._wrapper_options)
+ end
+ end
end
class NamespacedParamsWrapperTest < ActionController::TestCase
View
2  railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
@@ -4,7 +4,7 @@
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
-ActionController::Base.wrap_parameters <%= key_value :format, "[:json]" %>
+<%= app_const %>.config.wrap_parameters <%= key_value :format, "[:json]" %>
# Disable root element in JSON by default.
if defined?(ActiveRecord)
Please sign in to comment.
Something went wrong with that request. Please try again.