aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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]
* Merge pull request #26905 from bogdanvlviv/docsAndrew White2016-11-131-1/+1
|\ | | | | Add missing `+` around a some literals.
| * Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | | | | | | | Mainly around `nil` [ci skip]
* | removes unconventional "then" in case expressionXavier Noria2016-11-131-1/+1
| |
* | revises style in recent code (of mine)Xavier Noria2016-11-131-5/+7
| | | | | | | | | | This alternative case expressions read better for my taste, and look more uniform in a file where other similar case expressions are used (without dynamic clauses).
* | significant speedup of AC::Parameters#permitXavier Noria2016-11-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of AC::Parameters#permit builds permitted hashes and then calls permit! on them. This filtering is recursive, so we call permit! on terminal branches, but then ascendants call permit! on themselves when the recursion goes up the stack, which recurses all the way down again because permit! is recursive itself. Repeat this for every parent node and you get some scary O-something going on that I don't even want to compute. Instead, since the whole point of the permit recursion is to build permitted hashes along the way and at that point you know you've just come up with a valid filtered version, you can already switch the toggle on the spot. I have seen 2x speedups in casual benchmarks with small structures. As the previous description shows, the difference in performance is going to be a function of the nesting. Note that that the involved methods are private and used only by permit.
* | adds a missing dot [ci skip]Xavier Noria2016-11-111-1/+1
| |
* | adds support for arbitrary hashes in strong parametersXavier Noria2016-11-111-0/+45
| |
* | Merge pull request #26820 from y-yagi/add_bang_merge_to_parametersRafael França2016-11-101-0/+7
|\ \ | | | | | | add `ActionController::Parameters#merge!`
| * | add `ActionController::Parameters#merge!`yuuji.yaginuma2016-10-181-0/+7
| |/ | | | | | | | | This method has the same behavior as `Hash#merge!`, returns current `ActionController::Parameters`.
* / Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|/
* ActionController::Parameters#deep_dup (#26567)Pavel Evstigneev2016-10-111-0/+7
| | | | | | | | | | | * ActionController::Parameters#deep_dup * Tests for ActionController::Parameters#deep_dup * Fix test for ActionController::Parameters#deep_dup * More tests for ActionController::Parameters#deep_dup [Rafael Mendonça França + Pavel Evstigneev]
* Remove deprecated methods in ActionController::ParametersRafael Mendonça França2016-10-101-20/+0
|
* Remove deprecated comparing support with `ActionController::Parameters`Rafael Mendonça França2016-10-101-9/+0
|