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

13 commits

Author SHA1 Message Date
schneems
3f2ac413b7 Add methods to StrongParameters
It's reasonable to expose different value readers.
2016-01-19 12:06:29 -06:00
schneems
66d705b3e7 [close #23084] Deprecated StrongParameters
We can provide a more flexible upgrade experience by warning users they are using unsafe methods instead of forcing the safe API by deprecating before removal. This PR provides this functionality.
2016-01-19 12:05:44 -06:00
Xavier Noria
cbe7899f9d revises 877e42e
* A string in the example lacked quotes.

* The tests asserted stuff about :last_name, whereas
  test params do not have that key.

* But, the first one passed, why? After hitting my head against
  the wall and doing some obscure rituals realized the new
  #require had an important typo, wanted to iterate over the
  array argument (key), but it ran over its own hash keys
  (method #keys).

* Modified the test to prevent the same typo to happen again.

* The second test assigned to an unused variable safe_params
  that has been therefore removed.

* Grammar of the second test description.

* Since I was on it, reworded both test descriptions.
2015-08-28 17:15:20 +02:00
Gaurish Sharma
877e42e232 [Feature] params.require requires array of params
This PR adds ability to accept arrays which allows you to require multiple values in one method. so instead of this:

```ruby
params.require(:person).require(:first_name)
params.require(:person).require(:last_name)
```

Here it will be one line for each params, so say if I require 10params, it will be 10lines of repeated code which is not dry. So I have added new method which does this in one line:

```ruby
params.require(:person).require([:first_name, :last_name])
```

Comments welcome
2015-08-28 18:02:13 +05:30
Kir Shatrov
baf14ae513 Switch to kwargs in ActionController::TestCase and ActionDispatch::Integration
Non-kwargs requests are deprecated now.
Guides are updated as well.

`post url, nil, nil, { a: 'b' }` doesn't make sense.
`post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
2015-01-29 14:44:46 +02:00
Matthew Draper
497def80b5 Merge pull request #15692 from sromano/falseClass
ActionController::Parameters#require now accepts FalseClass values
2014-06-14 06:14:19 +09:30
Sergio Romano
540d153531 ActionController::Parameters#require now accepts FalseClass values
Fixes #15685.
2014-06-13 14:42:38 -03:00
Arthur Neves
aae53d2175 unify param.require tests 2014-01-23 22:28:24 -05:00
Guillermo Iguaran
f886fe2d8c Revert "Merge pull request #9660 from sebasoga/change_strong_parameters_require_behaviour"
This reverts commit c2b5a8e61b, reversing
changes made to 1918b12c04.

See: https://github.com/rails/rails/pull/9660#issuecomment-27627493
2013-11-02 14:30:03 -05:00
Sebastian Sogamoso
b3f894c528 Change ActionController::Parameters#require behavior when value is empty
When the value for the required key is empty an ActionController::ParameterMissing is raised which gets caught by ActionController::Base and turned into a 400 Bad Request reply with a message in the body saying the key is missing, which is misleading.

With these changes, ActionController::EmptyParameter will be raised which ActionController::Base will catch and turn into a 400 Bad Request reply with a message in the body saying the key value is empty.
2013-03-11 09:28:22 -05:00
Carlos Antonio da Silva
e5f5863e86 Remove warnings: "(...) interpreted as grouped expression" 2013-01-16 09:41:08 -02:00
Brian Alexander
8e221127ab strong parameters exception handling 2013-01-15 17:45:34 -07:00
Guillermo Iguaran
885005461b Integrate ActionController::Parameters from StrongParameters gem 2012-09-16 23:58:19 -05:00