1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't refer to ActionController::Base in the wrap_parameters initializer - use config object instead. Cuts about 15% off the load time. (#734)

This commit is contained in:
Jon Leighton 2011-08-16 00:59:59 +01:00
parent 03a045b306
commit 6c5f67cac1
3 changed files with 10 additions and 1 deletions

View file

@ -121,6 +121,8 @@ module ActionController
_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 file

@ -180,6 +180,13 @@ class ParamsWrapperTest < ActionController::TestCase
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 file

@ -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)