aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use match? where we don't need MatchDataAkira Matsuda2019-07-291-1/+1
|
* Merge pull request #36412 from robotdana/compact_blankRafael Mendonça França2019-07-251-0/+12
|\ | | | | | | Add compact_blank shortcut for reject(&:blank?)
| * Add compact_blank shortcut for reject(&:blank?)Dana Sherson2019-06-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | I frequently find myself having to .compact but for blank. which means on an array reject(&:blank?) (this is fine), or, on a hash `.reject { |_k, v| v.blank? }` which is slightly more frustrating and i usually write it as .reject(&:blank?) first and am confused when it's trying to check if the keys are blank. I've added the analagous .compact_blank! where there's a reject! to build on (there's also a reject! in Set, but there's no other core_ext touching Set so i've left that alone)
* | Add hash method to ActionController::ParametersEugene Baranov2019-07-141-0/+5
|/
* Implemented deep_transform_keys/! for ActionController::ParametersGustavo Gutierrez2019-05-221-0/+17
|
* Return parameters enumerator from transform_keys/!Eugene Kenny2019-05-181-7/+5
| | | | | | | | | | | | | | | | | Previously calling `ActionController::Parameters#transform_keys/!` without passing a block would return an enumerator for the underlying hash, which was inconsistent with the behaviour when a block was passed: ActionController::Parameters.new(foo: "bar").transform_keys { |k| k } => <ActionController::Parameters {"foo"=>"bar"} permitted: false> ActionController::Parameters.new(foo: "bar").transform_keys.each { |k| k } => {"foo"=>"bar"} An enumerator for the parameters is now returned instead, ensuring that evaluating it produces another parameters object instead of a hash: ActionController::Parameters.new(foo: "bar").transform_keys.each { |k| k } => <ActionController::Parameters {"foo"=>"bar"} permitted: false>
* fixed usage of Parameters when a non-numeric key existsL.Fexon2019-05-131-7/+17
| | | | | | | | | | test for non-numeric key in nested attributes test: extra blank line between tests removed test for non-numeric key fixed (by Daniel) Update according to feedback
* Remove unused modules from StrongParametersPatrik Bóna2019-04-151-4/+0
| | | | | | Unless I'm missing some undocumented use case, these modules aren't needed in `StrongParameters` anymore since 8e221127ab. Also, all actionpack tests are passing without them.
* Typo fixes action pack.alkesh262019-01-261-1/+1
|
* Fix `ActionController::Parameters#each_value` and add changelog entry to ↵Bogdan2018-10-151-1/+1
| | | | | | | | | | | | | this method (#34210) * Fix `ActionController::Parameters#each_value` `each_value` should yield with "value" of the params instead of "value" as an array. Related to #33979 * Add changelog entry about `ActionController::Parameters#each_value`. Follow up #33979
* Added ActionController::Parameters.each_value methodLukas Zapletal2018-09-271-0/+8
|
* Faster permitted_scalar_filterschneems2018-08-311-8/+20
| | | | | | | | | | | When running with code triage and derailed benchmarks and focusing on this file: Before 16199 /Users/rschneeman/Documents/projects/rails/actionpack/lib/action_controller/metal/strong_parameters.r After 2280 /Users/rschneeman/Documents/projects/rails/actionpack/lib/action_controller/metal/strong_parameters.rb
* [ci skip] Document permitted_scalar_filterschneems2018-08-301-0/+10
|
* Permit list usage cleanup and clearer documentationKevin Deisz2018-08-271-2/+2
|
* Convert over the rest of the whitelist referencesKevin Deisz2018-08-241-5/+5
|
* Turn on performance based copsDillon Welch2018-07-231-3/+1
| | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* Convert hashes into parameters (#33076)Kevin Sjöberg2018-06-191-10/+8
| | | | | | | | | | | | * Convert hashes into parameters Ensure `ActionController::Parameters#transform_values` and `ActionController::Parameters#transform_values!` converts hashes into parameters. * fixup! Convert hashes into parameters [Rafael Mendonça França + Kevin Sjöberg]
* Fix documentation for ActionController::Params#fetchLinus Marton2018-05-181-1/+3
| | | | | Make it clear that the return value is converted to an instance of ActionController::Parameters if possible
* Fixes StrongParameters permit! to work with nested arraysSteve Hull2018-04-161-1/+1
| | | | | `permit!` is intended to mark all instances of `ActionController::Parameters` as permitted, however nested arrays of params were not being marked permitted because the method did shallow iteration. This fixes that by flattening the array before calling `permit!` on all each item.
* Make mutating params#dig mutate underlying paramsVince DeVendra2018-03-241-1/+2
| | | | | | | | | | | When #dig was called on a params object and return either a Hash or an Array, and that value was subsquently mutated, it would not modify the containing params object. That means that the behavior of `params.dig(:a, :b)[:c] = 1` did not match either `params[:a][:b][:c] = 1` nor `hash.dig(:a, :b)[:c] = 1`. Similarly to `ActionController::Parameters#[]`, use `#convert_hashes_to_parameters` to pre-convert values and insert them in the receiving params object prior to returning them.
* Remove unnecessary `Hash.method_defined?(:dig)` checkingyuuji.yaginuma2018-03-111-13/+11
| | | | Since Rails 6 requires Ruby 2.4.1+.
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-171-1/+0
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Yield array from AC::Parameters#each for block with one argDominic Cleal2017-12-061-1/+1
| | | | Matches Hash#each behaviour as used in Rails 4.
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* Fix typo in API docsRyan Lue2017-07-201-1/+1
|
* Correct API documentation for ActionController::Parameters#deleteRyan Lue2017-07-201-4/+4
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| |
* | Fix format of `ActionController::Parameters#to_s` doc [ci skip]yuuji.yaginuma2017-07-011-0/+1
| |
* | Fallback Parameters#to_s to Hash#to_sKir Shatrov2017-06-301-1/+8
|/ | | Fixes https://github.com/rails/rails/issues/29617
* Fix typo in `AC::UnfilteredParameters` message [ci skip]yuuji.yaginuma2017-06-231-2/+2
| | | | Ref: https://github.com/rails/rails/blob/33b596709388cc48d90ab6d1de99d7bd6e85f916/actionpack/lib/action_controller/metal/strong_parameters.rb#L52..L56
* Fix examples for `AC::Parameters#to_query` [ci skip]yuuji.yaginuma2017-06-191-1/+6
| | | | | | | | | | | | | | | Without `permit`, `AC::Parameters#to_query` raise `AC::UnfilteredParameters`. ```ruby params = ActionController::Parameters.new({ name: "David", nationality: "Danish" }) params.to_query # => ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash ```
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-4/+2
|
* Pass block in ActionController::Parameters#deleteEugene Kenny2017-05-101-2/+2
| | | | | | | | In order to fully support the same interface as `Hash#delete`, we need to pass the block through to the underlying method, not just the key. This used to work correctly, but it regressed when `ActionController::Parameters` stopped inheriting from `Hash` in 5.0.
* Reuse the Parameters#to_h check in the routing helpersRafael Mendonça França2017-04-181-1/+1
| | | | | Since this protection is now in Parameters we can use it instead of reimplementing again.
* Follow the style guide rules in the documetationRafael Mendonça França2017-04-181-30/+30
|
* Improve documentationRafael Mendonça França2017-04-181-4/+4
| | | | | | We are talking about a list of parameters even so we need to use plural. Even if we were talking about the instance of the Parameters object we would have to use the capital and monospaced font.
* Implement ActionController::Parameters#to_query and #to_paramRafael Mendonça França2017-04-181-2/+28
| | | | | | | | | | Previously it was raising an error because it may be unsafe to use those methods in a unpermitted parameter. Now we delegate to to_h that already raise an error when the Parameters instance is not permitted. This also fix a bug when using `#to_query` in a hash that contains a `ActionController::Parameters` instance and was returning the name of the class in the string.
* Add ActionController::Parameters#to_hash to implict conversionRafael Mendonça França2017-04-181-0/+16
| | | | | | | | Now methods that implicit convert objects to a hash will be able to work without requiring the users to change their implementation. This method will return a Hash instead of a HashWithIndefirentAccess to mimic the same implementation of HashWithIndefirentAccess#to_hash.
* Raise exception when calling to_h in a unfiltered ParametersRafael Mendonça França2017-04-181-2/+15
| | | | | | | | | | | | | | | | Before we returned either an empty hash or only the always permitted parameters (:controller and :action by default). The previous behavior was dangerous because in order to get the attributes users usually fallback to use to_unsafe_h that could potentially introduce security issues. The to_unsafe_h API is also not good since Parameters is a object that quacks like a Hash but not in all cases since to_h would return an empty hash and users were forced to check if to_unsafe_h is defined or if the instance is a ActionController::Parameters in order to work with it. This end up coupling a lot of libraries and parts of the application with something that is from the controller layer.
* Add aliases for reverse_merge to with_defaultsMatt Casper2017-03-291-0/+2
| | | | | | In the context of controller parameters, reverse_merge is commonly used to provide defaults for user input. Having an alias to reverse_merge called with_defaults feels more idiomatic for Rails.
* [docs] fix ActionController documentationHrvoje Šimić2017-03-121-8/+8
| | | | [ci skip]
* Added `reverse_merge`/`reverse_merge!` to AC::Parameters:Edouard CHIN2017-03-091-0/+15
| | | | | - This PR adds the `reverse_merge` and `reverse_merge!` method to `ActionController::Parameters` - Fixes #28353
* params --> parametersJon Moss2017-03-071-2/+2
| | | | [ci skip]
* Document delegated public methods on AC::ParametersT.J. Schuck2017-03-071-0/+71
| | | [ci skip]
* [ci skip] Fix ParameterMissing exception name in docsTejas Bubane2017-03-041-1/+1
| | | | | | | | Should be `ActionController::ParameterMissing` and not `ActionController::MissingParameter`. Corresponding change was done in guides in https://github.com/rails/rails/pull/9816.
* Revert "significant speedup of AC::Parameters#permit" ↵David Heinemeier Hansson2017-01-161-3/+1
| | | | [26dd9b26ab7317f94fd285245879e888344143b2] as it broke Parameters#to_h on at least fields_for-style nested params.
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Document 'false' as option for 'action_on_unpermitted_parameters'Daniel Carral2016-11-291-2/+2
| | | | [ci skip]