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

Virtus patching causes unintended consequences #113

Closed
cmoylan opened this issue Aug 16, 2017 · 2 comments
Closed

Virtus patching causes unintended consequences #113

cmoylan opened this issue Aug 16, 2017 · 2 comments
Assignees

Comments

@cmoylan
Copy link

cmoylan commented Aug 16, 2017

First off, 👍 to #98

I upgraded the tracker_api on a grape API and noticed that boolean params set to false were becoming nil. I set up a small app to demonstrate this - https://github.com/cmoylan/tracker_grape_example

# without tracker_api in the Gemfile
$ curl localhost:9292/test?my_param=false
false%
$ curl localhost:9292/test?my_param=true
true%
$ curl localhost:9292/test?my_param=asdf
my_param is invalid%


# with tracker_api in Gemfile
$ curl localhost:9292/test?my_param=false

$ curl localhost:9292/test?my_param=true
true%
$ curl localhost:9292/test?my_param=asdf
my_param is invalid%

This is happening because grape uses virtus and tracker_api is adding this bit - https://github.com/dashofcode/tracker_api/blob/master/lib/virtus/attribute/nullify_blank.rb#L17. An additional check like && output != false would solve it. Or just use this as more motivation to ditch virtus entirely.

@forest
Copy link
Contributor

forest commented Aug 16, 2017

Thanks for the heads up. I'll add the check and keep working on #98. That is the real solution. :)

@forest forest self-assigned this Aug 16, 2017
forest added a commit that referenced this issue Aug 16, 2017
@cmoylan
Copy link
Author

cmoylan commented Aug 17, 2017

Thanks for the quick response. Let me know if there's anything I can do to make #98 a reality.

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

2 participants