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

numericality matcher can only handle column-backed attributes #831

Closed
ksol opened this issue Nov 5, 2015 · 2 comments
Closed

numericality matcher can only handle column-backed attributes #831

ksol opened this issue Nov 5, 2015 · 2 comments

Comments

@ksol
Copy link

ksol commented Nov 5, 2015

Hello,

Since upgrading to 3.0.1 some of my validate_numericality_of are failing with this error :

NoMethodError: undefined method `type' for nil:NilClass
from ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/shoulda-matchers-3.0.1/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb:442:in `column_type'

After a little bit of research, this is because the attribute I'm not validating is not (directly) backed by a column. In my case, the attribute is a "shortcut" accessor for data nested in a json column (in postgre), so there is no column-type associated.

I don't know how this should be handled, but if someone were to point me in the right direction, I'd be happy to fix this myself and open a PR.

Thanks for your time, and have a nice day !

@mcmire
Copy link
Collaborator

mcmire commented Nov 5, 2015

You're in luck, because there's already a PR open to fix this issue: #822 :)

I've been a little short on time lately, but I will try to merge it in soon.

@ksol
Copy link
Author

ksol commented Nov 5, 2015

eh, my bad. I only checked for issues, not PRs. Thanks for the update !

@mcmire mcmire closed this as completed Nov 5, 2015
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