actionpack 3.1.0.beta1 → 3.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (52) hide show
  1. data/CHANGELOG +57 -4
  2. data/README.rdoc +5 -5
  3. data/lib/abstract_controller/base.rb +25 -13
  4. data/lib/abstract_controller/callbacks.rb +2 -2
  5. data/lib/abstract_controller/layouts.rb +3 -3
  6. data/lib/abstract_controller/rendering.rb +22 -6
  7. data/lib/abstract_controller/url_for.rb +6 -0
  8. data/lib/abstract_controller/view_paths.rb +1 -1
  9. data/lib/action_controller/log_subscriber.rb +3 -1
  10. data/lib/action_controller/metal/compatibility.rb +4 -7
  11. data/lib/action_controller/metal/implicit_render.rb +7 -9
  12. data/lib/action_controller/metal/instrumentation.rb +1 -1
  13. data/lib/action_controller/metal/params_wrapper.rb +37 -26
  14. data/lib/action_controller/metal/request_forgery_protection.rb +4 -1
  15. data/lib/action_controller/metal/responder.rb +6 -1
  16. data/lib/action_controller/metal/url_for.rb +21 -0
  17. data/lib/action_controller/test_case.rb +6 -1
  18. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +1 -1
  19. data/lib/action_dispatch/http/cache.rb +12 -14
  20. data/lib/action_dispatch/http/rack_cache.rb +6 -2
  21. data/lib/action_dispatch/http/response.rb +41 -15
  22. data/lib/action_dispatch/http/url.rb +1 -1
  23. data/lib/action_dispatch/middleware/cookies.rb +3 -3
  24. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +1 -1
  25. data/lib/action_dispatch/routing.rb +3 -3
  26. data/lib/action_dispatch/routing/mapper.rb +33 -28
  27. data/lib/action_dispatch/routing/route_set.rb +6 -3
  28. data/lib/action_dispatch/routing/url_for.rb +4 -4
  29. data/lib/action_dispatch/testing/assertions/selector.rb +1 -1
  30. data/lib/action_dispatch/testing/performance_test.rb +6 -13
  31. data/lib/action_dispatch/testing/test_process.rb +1 -1
  32. data/lib/action_pack/version.rb +1 -1
  33. data/lib/action_view.rb +1 -0
  34. data/lib/action_view/base.rb +5 -5
  35. data/lib/action_view/helpers/asset_paths.rb +0 -1
  36. data/lib/action_view/helpers/atom_feed_helper.rb +6 -6
  37. data/lib/action_view/helpers/cache_helper.rb +1 -1
  38. data/lib/action_view/helpers/capture_helper.rb +6 -2
  39. data/lib/action_view/helpers/date_helper.rb +119 -75
  40. data/lib/action_view/helpers/form_helper.rb +26 -36
  41. data/lib/action_view/helpers/form_options_helper.rb +2 -2
  42. data/lib/action_view/helpers/form_tag_helper.rb +6 -6
  43. data/lib/action_view/helpers/translation_helper.rb +4 -4
  44. data/lib/action_view/helpers/url_helper.rb +1 -1
  45. data/lib/action_view/lookup_context.rb +5 -5
  46. data/lib/action_view/path_set.rb +1 -1
  47. data/lib/action_view/template.rb +5 -5
  48. data/lib/action_view/template/error.rb +2 -0
  49. data/lib/action_view/template/handlers/erb.rb +0 -1
  50. data/lib/action_view/template/resolver.rb +37 -25
  51. data/lib/sprockets/railtie.rb +3 -3
  52. metadata +8 -8
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  *Rails 3.1.0 (unreleased)*
2
2
 
3
+ * Warn if we cannot verify CSRF token authenticity [José Valim]
4
+
5
+ * Allow AM/PM format in datetime selectors [Aditya Sanghi]
6
+
3
7
  * Only show dump of regular env methods on exception screen (not all the rack crap) [DHH]
4
8
 
5
9
  * auto_link has been removed with no replacement. If you still use auto_link
@@ -13,7 +17,7 @@
13
17
  class PostsController < ActionController::Base
14
18
  stream :only => :index
15
19
  end
16
-
20
+
17
21
  Please read the docs at `ActionController::Streaming` for more information.
18
22
 
19
23
  * Added `ActionDispatch::Request.ignore_accept_header` to ignore accept headers and only consider the format given as parameter [José Valim]
@@ -114,8 +118,6 @@ tested.
114
118
 
115
119
  Keys are dasherized. Values are JSON-encoded, except for strings and symbols. [Stephen Celis]
116
120
 
117
- * Added render :once. You can pass either a string or an array of strings and Rails will ensure they each of them are rendered just once. [José Valim]
118
-
119
121
  * Deprecate old template handler API. The new API simply requires a template handler to respond to call. [José Valim]
120
122
 
121
123
  * :rhtml and :rxml were finally removed as template handlers. [José Valim]
@@ -131,7 +133,58 @@ tested.
131
133
  * Add Rack::Cache to the default stack. Create a Rails store that delegates to the Rails cache, so by default, whatever caching layer you are using will be used for HTTP caching. Note that Rack::Cache will be used if you use #expires_in, #fresh_when or #stale with :public => true. Otherwise, the caching rules will apply to the browser only. [Yehuda Katz, Carl Lerche]
132
134
 
133
135
 
134
- *Rails 3.0.2 (unreleased)*
136
+ *Rails 3.0.7 (April 18, 2011)*
137
+
138
+ *No changes.
139
+
140
+
141
+ *Rails 3.0.6 (April 5, 2011)
142
+
143
+ * Fixed XSS vulnerability in `auto_link`. `auto_link` no longer marks input as
144
+ html safe. Please make sure that calls to auto_link() are wrapped in a
145
+ sanitize(), or a raw() depending on the type of input passed to auto_link().
146
+ For example:
147
+
148
+ <%= sanitize(auto_link(some_user_input)) %>
149
+
150
+ Thanks to Torben Schulz for reporting this. The fix can be found here:
151
+ 61ee3449674c591747db95f9b3472c5c3bd9e84d
152
+
153
+ * Fixes the output of `rake routes` to be correctly match to the behavior of the application, as the regular expression used to match the path is greedy and won't capture the format part by default [Prem Sichanugrist]
154
+
155
+ * Fixes an issue with number_to_human when converting values which are less than 1 but greater than -1 [Josh Kalderimis]
156
+
157
+ * Sensitive query string parameters (specified in config.filter_parameters) will now be filtered out from the request paths in the log file. [Prem Sichanugrist, fxn]
158
+
159
+ * URL parameters which return nil for to_param are now removed from the query string [Andrew White]
160
+
161
+ * Don't allow i18n to change the minor version, version now set to ~> 0.5.0 [Santiago Pastorino]
162
+
163
+ * Make TranslationHelper#translate use the :rescue_format option in I18n 0.5.0 [Sven Fuchs]
164
+
165
+ * Fix regression: javascript_include_tag shouldn't raise if you register an expansion key with nil or [] value [Santiago Pastorino]
166
+
167
+ * Fix Action caching bug where an action that has a non-cacheable response always renders a nil response body. It now correctly renders the response body. [Cheah Chu Yeow]
168
+
169
+
170
+ *Rails 3.0.5 (February 26, 2011)*
171
+
172
+ * No changes.
173
+
174
+
175
+ *Rails 3.0.4 (February 8, 2011)*
176
+
177
+ * No changes.
178
+
179
+
180
+ *Rails 3.0.3 (November 16, 2010)*
181
+
182
+ * When ActiveRecord::Base objects are sent to predicate methods, the id of the object should be sent to ARel, not the ActiveRecord::Base object.
183
+
184
+ * :constraints routing should only do sanity checks against regular expressions. String arguments are OK.
185
+
186
+
187
+ *Rails 3.0.2 (November 15, 2010)*
135
188
 
136
189
  * The helper number_to_currency accepts a new :negative_format option to be able to configure how to render negative amounts. [Don Wilson]
137
190
 
@@ -33,7 +33,7 @@ A short rundown of some of the major features:
33
33
  * Actions grouped in controller as methods instead of separate command objects
34
34
  and can therefore share helper methods
35
35
 
36
- CustomersController < ActionController::Base
36
+ class CustomersController < ActionController::Base
37
37
  def show
38
38
  @customer = find_customer
39
39
  end
@@ -58,7 +58,7 @@ A short rundown of some of the major features:
58
58
 
59
59
  * ERB templates (static content mixed with dynamic output from ruby)
60
60
 
61
- <% for post in @posts %>
61
+ <% @posts.each do |post| %>
62
62
  Title: <%= post.title %>
63
63
  <% end %>
64
64
 
@@ -81,7 +81,7 @@ A short rundown of some of the major features:
81
81
  xml.language "en-us"
82
82
  xml.ttl "40"
83
83
 
84
- for item in @recent_items
84
+ @recent_items.each do |item|
85
85
  xml.item do
86
86
  xml.title(item_title(item))
87
87
  xml.description(item_description(item))
@@ -293,7 +293,7 @@ And the templates look like this:
293
293
  </body></html>
294
294
 
295
295
  weblog/index.html.erb:
296
- <% for post in @posts %>
296
+ <% @posts.each do |post| %>
297
297
  <p><%= link_to(post.title, :action => "show", :id => post.id) %></p>
298
298
  <% end %>
299
299
 
@@ -338,4 +338,4 @@ API documentation is at
338
338
 
339
339
  Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
340
340
 
341
- * https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets
341
+ * https://github.com/rails/rails/issues
@@ -130,27 +130,39 @@ module AbstractController
130
130
  self.class.action_methods
131
131
  end
132
132
 
133
- # Returns true if the name can be considered an action. This can
134
- # be overridden in subclasses to modify the semantics of what
135
- # can be considered an action.
133
+ # Returns true if a method for the action is available and
134
+ # can be dispatched, false otherwise.
136
135
  #
137
- # For instance, this is overriden by ActionController to add
138
- # the implicit rendering feature.
139
- #
140
- # ==== Parameters
141
- # * <tt>name</tt> - The name of an action to be tested
142
- #
143
- # ==== Returns
144
- # * <tt>TrueClass</tt>, <tt>FalseClass</tt>
145
- def action_method?(name)
146
- self.class.action_methods.include?(name)
136
+ # Notice that <tt>action_methods.include?("foo")</tt> may return
137
+ # false and <tt>available_action?("foo")</tt> returns true because
138
+ # available action consider actions that are also available
139
+ # through other means, for example, implicit render ones.
140
+ def available_action?(action_name)
141
+ method_for_action(action_name).present?
147
142
  end
148
143
 
149
144
  private
150
145
 
146
+ # Returns true if the name can be considered an action because
147
+ # it has a method defined in the controller.
148
+ #
149
+ # ==== Parameters
150
+ # * <tt>name</tt> - The name of an action to be tested
151
+ #
152
+ # ==== Returns
153
+ # * <tt>TrueClass</tt>, <tt>FalseClass</tt>
154
+ #
155
+ # :api: private
156
+ def action_method?(name)
157
+ self.class.action_methods.include?(name)
158
+ end
159
+
151
160
  # Call the action. Override this in a subclass to modify the
152
161
  # behavior around processing an action. This, and not #process,
153
162
  # is the intended way to override action dispatching.
163
+ #
164
+ # Notice that the first argument is the method to be dispatched
165
+ # which is *not* necessarily the same as the action name.
154
166
  def process_action(method_name, *args)
155
167
  send_action(method_name, *args)
156
168
  end
@@ -13,8 +13,8 @@ module AbstractController
13
13
 
14
14
  # Override AbstractController::Base's process_action to run the
15
15
  # process_action callbacks around the normal behavior.
16
- def process_action(method_name, *args)
17
- run_callbacks(:process_action, method_name) do
16
+ def process_action(*args)
17
+ run_callbacks(:process_action, action_name) do
18
18
  super
19
19
  end
20
20
  end
@@ -292,15 +292,15 @@ module AbstractController
292
292
  end
293
293
  end
294
294
 
295
- attr_writer :action_has_layout
295
+ attr_internal_writer :action_has_layout
296
296
 
297
297
  def initialize(*)
298
- @action_has_layout = true
298
+ @_action_has_layout = true
299
299
  super
300
300
  end
301
301
 
302
302
  def action_has_layout?
303
- @action_has_layout
303
+ @_action_has_layout
304
304
  end
305
305
 
306
306
  private
@@ -32,9 +32,13 @@ module AbstractController
32
32
 
33
33
  module Rendering
34
34
  extend ActiveSupport::Concern
35
-
36
35
  include AbstractController::ViewPaths
37
36
 
37
+ included do
38
+ config_accessor :protected_instance_variables, :instance_reader => false
39
+ self.protected_instance_variables = []
40
+ end
41
+
38
42
  # Overwrite process to setup I18n proxy.
39
43
  def process(*) #:nodoc:
40
44
  old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context)
@@ -53,14 +57,20 @@ module AbstractController
53
57
  end
54
58
  end
55
59
 
56
- attr_writer :view_context_class
60
+ attr_internal_writer :view_context_class
61
+
62
+ # Explicitly define protected_instance_variables so it can be
63
+ # inherited and overwritten by other modules if needed.
64
+ def protected_instance_variables
65
+ config.protected_instance_variables
66
+ end
57
67
 
58
68
  def view_context_class
59
- @view_context_class || self.class.view_context_class
69
+ @_view_context_class || self.class.view_context_class
60
70
  end
61
71
 
62
72
  def initialize(*)
63
- @view_context_class = nil
73
+ @_view_context_class = nil
64
74
  super
65
75
  end
66
76
 
@@ -79,7 +89,7 @@ module AbstractController
79
89
 
80
90
  # Returns an object that is able to render templates.
81
91
  def view_renderer
82
- @view_renderer ||= ActionView::Renderer.new(lookup_context)
92
+ @_view_renderer ||= ActionView::Renderer.new(lookup_context)
83
93
  end
84
94
 
85
95
  # Normalize arguments, options and then delegates render_to_body and
@@ -112,13 +122,19 @@ module AbstractController
112
122
 
113
123
  private
114
124
 
125
+ DEFAULT_PROTECTED_INSTANCE_VARIABLES = %w(
126
+ @_action_name @_response_body @_formats @_prefixes @_config
127
+ @_view_context_class @_view_renderer @_lookup_context
128
+ )
129
+
115
130
  # This method should return a hash with assigns.
116
131
  # You can overwrite this configuration per controller.
117
132
  # :api: public
118
133
  def view_assigns
119
134
  hash = {}
120
135
  variables = instance_variable_names
121
- variables -= protected_instance_variables if respond_to?(:protected_instance_variables)
136
+ variables -= protected_instance_variables
137
+ variables -= DEFAULT_PROTECTED_INSTANCE_VARIABLES
122
138
  variables.each { |name| hash[name.to_s[1, name.length]] = instance_variable_get(name) }
123
139
  hash
124
140
  end
@@ -1,3 +1,9 @@
1
+ # Includes +url_for+ into the host class (e.g. an abstract controller or mailer). The class
2
+ # has to provide a +RouteSet+ by implementing the <tt>_routes</tt> methods. Otherwise, an
3
+ # exception will be raised.
4
+ #
5
+ # Note that this module is completely decoupled from HTTP - the only requirement is a valid
6
+ # <tt>_routes</tt> implementation.
1
7
  module AbstractController
2
8
  module UrlFor
3
9
  extend ActiveSupport::Concern
@@ -39,7 +39,7 @@ module AbstractController
39
39
  # templates, i.e. view paths and details. Check ActionView::LookupContext for more
40
40
  # information.
41
41
  def lookup_context
42
- @lookup_context ||=
42
+ @_lookup_context ||=
43
43
  ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)
44
44
  end
45
45
 
@@ -7,8 +7,10 @@ module ActionController
7
7
  def start_processing(event)
8
8
  payload = event.payload
9
9
  params = payload[:params].except(*INTERNAL_PARAMS)
10
+ format = payload[:format]
11
+ format = format.to_s.upcase if format.is_a?(Symbol)
10
12
 
11
- info " Processing by #{payload[:controller]}##{payload[:action]} as #{payload[:formats].first.to_s.upcase}"
13
+ info " Processing by #{payload[:controller]}##{payload[:action]} as #{format}"
12
14
  info " Parameters: #{params.inspect}" unless params.empty?
13
15
  end
14
16
 
@@ -18,13 +18,10 @@ module ActionController
18
18
  delegate :default_charset=, :to => "ActionDispatch::Response"
19
19
  end
20
20
 
21
- # TODO: Update protected instance variables list
22
- config_accessor :protected_instance_variables
23
- self.protected_instance_variables = %w(@assigns @performed_redirect @performed_render
24
- @variables_added @request_origin @url
25
- @parent_controller @action_name
26
- @before_filter_chain_aborted @_headers @_params
27
- @_response)
21
+ self.protected_instance_variables = %w(
22
+ @_status @_headers @_params @_env @_response @_request
23
+ @_view_runtime @_stream @_url_options @_action_has_layout
24
+ )
28
25
 
29
26
  def rescue_action(env)
30
27
  raise env["action_dispatch.rescue.exception"]
@@ -1,21 +1,19 @@
1
1
  module ActionController
2
2
  module ImplicitRender
3
3
  def send_action(method, *args)
4
- if respond_to?(method, true)
5
- ret = super
6
- default_render unless response_body
7
- ret
8
- else
9
- default_render
10
- end
4
+ ret = super
5
+ default_render unless response_body
6
+ ret
11
7
  end
12
8
 
13
9
  def default_render(*args)
14
10
  render(*args)
15
11
  end
16
12
 
17
- def action_method?(action_name)
18
- super || template_exists?(action_name.to_s, _prefixes)
13
+ def method_for_action(action_name)
14
+ super || if template_exists?(action_name.to_s, _prefixes)
15
+ "default_render"
16
+ end
19
17
  end
20
18
  end
21
19
  end
@@ -19,7 +19,7 @@ module ActionController
19
19
  :controller => self.class.name,
20
20
  :action => self.action_name,
21
21
  :params => request.filtered_parameters,
22
- :formats => request.formats.map(&:to_sym),
22
+ :format => request.format.ref,
23
23
  :method => request.method,
24
24
  :path => (request.fullpath rescue "unknown")
25
25
  }
@@ -2,6 +2,7 @@ require 'active_support/core_ext/class/attribute'
2
2
  require 'active_support/core_ext/hash/slice'
3
3
  require 'active_support/core_ext/hash/except'
4
4
  require 'active_support/core_ext/array/wrap'
5
+ require 'active_support/core_ext/module/anonymous'
5
6
  require 'action_dispatch/http/mime_types'
6
7
 
7
8
  module ActionController
@@ -36,11 +37,11 @@ module ActionController
36
37
  # {"name" => "Konata", "user" => {"name" => "Konata"}}
37
38
  #
38
39
  # You can also specify the key in which the parameters should be wrapped to,
39
- # and also the list of attributes it should wrap by using either +:only+ or
40
- # +:except+ options like this:
40
+ # and also the list of attributes it should wrap by using either +:include+ or
41
+ # +:exclude+ options like this:
41
42
  #
42
43
  # class UsersController < ApplicationController
43
- # wrap_parameters :person, :only => [:username, :password]
44
+ # wrap_parameters :person, :include => [:username, :password]
44
45
  # end
45
46
  #
46
47
  # If you're going to pass the parameters to an +ActiveModel+ object (such as
@@ -52,7 +53,7 @@ module ActionController
52
53
  # wrap_parameters Person
53
54
  # end
54
55
  #
55
- # You still could pass +:only+ and +:except+ to set the list of attributes
56
+ # You still could pass +:include+ and +:exclude+ to set the list of attributes
56
57
  # you want to wrap.
57
58
  #
58
59
  # By default, if you don't specify the key in which the parameters would be
@@ -72,7 +73,7 @@ module ActionController
72
73
 
73
74
  included do
74
75
  class_attribute :_wrapper_options
75
- self._wrapper_options = {:format => []}
76
+ self._wrapper_options = { :format => [] }
76
77
  end
77
78
 
78
79
  module ClassMethods
@@ -90,7 +91,7 @@ module ActionController
90
91
  # # wraps parameters by determine the wrapper key from Person class
91
92
  # (+person+, in this case) and the list of attribute names
92
93
  #
93
- # wrap_parameters :only => [:username, :title]
94
+ # wrap_parameters :include => [:username, :title]
94
95
  # # wraps only +:username+ and +:title+ attributes from parameters.
95
96
  #
96
97
  # wrap_parameters false
@@ -99,9 +100,9 @@ module ActionController
99
100
  # ==== Options
100
101
  # * <tt>:format</tt> - The list of formats in which the parameters wrapper
101
102
  # will be enabled.
102
- # * <tt>:only</tt> - The list of attribute names which parameters wrapper
103
+ # * <tt>:include</tt> - The list of attribute names which parameters wrapper
103
104
  # will wrap into a nested hash.
104
- # * <tt>:except</tt> - The list of attribute names which parameters wrapper
105
+ # * <tt>:exclude</tt> - The list of attribute names which parameters wrapper
105
106
  # will exclude from a nested hash.
106
107
  def wrap_parameters(name_or_model_or_options, options = {})
107
108
  model = nil
@@ -125,7 +126,7 @@ module ActionController
125
126
  # module is inherited.
126
127
  def inherited(klass)
127
128
  if klass._wrapper_options[:format].present?
128
- klass._set_wrapper_defaults(klass._wrapper_options)
129
+ klass._set_wrapper_defaults(klass._wrapper_options.slice(:format))
129
130
  end
130
131
  super
131
132
  end
@@ -136,15 +137,25 @@ module ActionController
136
137
  # this could be done by trying to find the defined model that has the
137
138
  # same singularize name as the controller. For example, +UsersController+
138
139
  # will try to find if the +User+ model exists.
139
- def _default_wrap_model
140
+ #
141
+ # This method also does namespace lookup. Foo::Bar::UsersController will
142
+ # try to find Foo::Bar::User, Foo::User and finally User.
143
+ def _default_wrap_model #:nodoc:
144
+ return nil if self.anonymous?
145
+
140
146
  model_name = self.name.sub(/Controller$/, '').singularize
141
147
 
142
148
  begin
143
149
  model_klass = model_name.constantize
144
- rescue NameError => e
145
- unscoped_model_name = model_name.split("::", 2).last
146
- break if unscoped_model_name == model_name
147
- model_name = unscoped_model_name
150
+ rescue NameError, ArgumentError => e
151
+ if e.message =~ /is not missing constant|uninitialized constant #{model_name}/
152
+ namespaces = model_name.split("::")
153
+ namespaces.delete_at(-2)
154
+ break if namespaces.last == model_name
155
+ model_name = namespaces.join("::")
156
+ else
157
+ raise
158
+ end
148
159
  end until model_klass
149
160
 
150
161
  model_klass
@@ -153,22 +164,22 @@ module ActionController
153
164
  def _set_wrapper_defaults(options, model=nil)
154
165
  options = options.dup
155
166
 
156
- unless options[:only] || options[:except]
167
+ unless options[:include] || options[:exclude]
157
168
  model ||= _default_wrap_model
158
- if model.respond_to?(:column_names)
159
- options[:only] = model.column_names
169
+ if model.respond_to?(:attribute_names) && model.attribute_names.present?
170
+ options[:include] = model.attribute_names
160
171
  end
161
172
  end
162
173
 
163
- unless options[:name]
174
+ unless options[:name] || self.anonymous?
164
175
  model ||= _default_wrap_model
165
176
  options[:name] = model ? model.to_s.demodulize.underscore :
166
177
  controller_name.singularize
167
178
  end
168
179
 
169
- options[:only] = Array.wrap(options[:only]).collect(&:to_s) if options[:only]
170
- options[:except] = Array.wrap(options[:except]).collect(&:to_s) if options[:except]
171
- options[:format] = Array.wrap(options[:format])
180
+ options[:include] = Array.wrap(options[:include]).collect(&:to_s) if options[:include]
181
+ options[:exclude] = Array.wrap(options[:exclude]).collect(&:to_s) if options[:exclude]
182
+ options[:format] = Array.wrap(options[:format])
172
183
 
173
184
  self._wrapper_options = options
174
185
  end
@@ -205,11 +216,11 @@ module ActionController
205
216
 
206
217
  # Returns the list of parameters which will be selected for wrapped.
207
218
  def _wrap_parameters(parameters)
208
- value = if only = _wrapper_options[:only]
209
- parameters.slice(*only)
219
+ value = if include_only = _wrapper_options[:include]
220
+ parameters.slice(*include_only)
210
221
  else
211
- except = _wrapper_options[:except] || []
212
- parameters.except(*(except + EXCLUDE_PARAMETERS))
222
+ exclude = _wrapper_options[:exclude] || []
223
+ parameters.except(*(exclude + EXCLUDE_PARAMETERS))
213
224
  end
214
225
 
215
226
  { _wrapper_key => value }
@@ -218,7 +229,7 @@ module ActionController
218
229
  # Checks if we should perform parameters wrapping.
219
230
  def _wrapper_enabled?
220
231
  ref = request.content_mime_type.try(:ref)
221
- _wrapper_formats.include?(ref) && !request.request_parameters[_wrapper_key]
232
+ _wrapper_formats.include?(ref) && _wrapper_key && !request.request_parameters[_wrapper_key]
222
233
  end
223
234
  end
224
235
  end