aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* call `.to_h` to avoid using deprecated methodyuuji.yaginuma2016-09-071-1/+1
| | | | | | | | | | | `ActionController::Parameters#merge` call `HashWithIndifferentAccess#merge`. In addition, it calls `HashWithIndifferentAccess#update` from `HashWithIndifferentAccess#merge`, where it is called the `#to_hash` of argument. But `ActionController::Parameters#to_hash` is deprecated, warning message is displayed. To avoid this, modify to convert object to `Hash`. Fixes #26415
* Move to_param undef closer to the deprecations.Kasper Timm Hansen2016-08-311-2/+4
| | | | | | | Makes it clearer why we're doing this Add a comment to elaborate on what the undef means and move it closer to the deprecations so it's less likely for whoever pulls the deprecations that it should go too.
* Do not allow to_param on AC::ParametersKir Shatrov2016-08-311-0/+3
|
* Merge pull request #26094 from igorkasyanchuk/masterRafael França2016-08-161-2/+2
|\ | | | | Show unpermitted parameters as symbols in logs (so they could be copy…
| * Show unpermitted parameters as symbols in logs (so they could be copy-pasted ↵Igor Kasyanchuk2016-08-101-2/+2
| | | | | | | | to the code)
* | Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
|/ | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-18/+18
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Move the YAML hook closer to `init_with`.Kasper Timm Hansen2016-08-021-8/+9
| | | | | Looked odd, so completely detached from the other necessary part of the implementation.