Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash.try_convert(attributes) errors on params in Rails 5 #389

Open
natesholland opened this issue Apr 12, 2018 · 0 comments
Open

Hash.try_convert(attributes) errors on params in Rails 5 #389

natesholland opened this issue Apr 12, 2018 · 0 comments

Comments

@natesholland
Copy link

I'm running into an error specifically with this line of code:

::Hash.try_convert(attributes) or raise(

In Rails 4 and below calling to_hash on parameters was easy and returned the expected hash as follows:

> ::Hash.try_convert(ActionController::Parameters.new({foo: "bar"}))
 => {"foo"=>"bar"}

However this behavior changed in Rails 5 and started to raise an error:

> ::Hash.try_convert(ActionController::Parameters.new({foo: "bar"}))
 => ActionController::UnfilteredParameters (unable to convert unpermitted parameters to hash)

Therefore I think Virtus needs to be slightly more intelligent about how it coerces to a hash.
I have gone ahead and implemented a PR that should fix the issue I am seeing as well as a test to replicate the issue and verify it's fix in #388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant