Commit 14e66ca
committed
FormHelper: convert params#to_unsafe_h only if Rails 5, add tests.
This adresses an issue correctly brought up by @ryanswood in PR #644
concerning Rails 4.2 where params#to_unsafe_h still needs to be
converted from a Hash to a HWIA to respond to symbol hash keys.
I prefer to trying adding a conditional on Active Record version rather
than an extra HWIA conversion.
The tests are run for Rails 4 and 5, since ActionController::Parameters
was backported to 4.x.
Rails 3 raises if ActionController::Parameters is invoked, so the tests
are skipped in that case.
This commit is necessary because when the following is run:
ActionController::Parameters.new(q: 1).to_unsafe_h.fetch(:q)
with Rails 5 it works, but not with Rails 4.2. The reason is that in
Rails 5, #to_unsafe_h calls
StrongParameters::convert_parameters_to_hashes which converts hashes to
HWIA, whereas in Rails 4.2 it just calls #to_hash without HWIA.1 parent 9072028 commit 14e66ca
File tree
2 files changed
+25
-11
lines changed- lib/ransack/helpers
- spec/ransack/helpers
2 files changed
+25
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 332 | + | |
| 333 | + | |
336 | 334 | | |
| 335 | + | |
337 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
338 | 341 | | |
339 | | - | |
340 | | - | |
341 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
342 | 347 | | |
| 348 | + | |
343 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
344 | 356 | | |
345 | 357 | | |
346 | 358 | | |
347 | 359 | | |
348 | | - | |
| 360 | + | |
349 | 361 | | |
350 | 362 | | |
351 | 363 | | |
352 | 364 | | |
353 | | - | |
354 | 365 | | |
355 | 366 | | |
356 | 367 | | |
| |||
0 commit comments