-
-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Numericality validation of virtual attributes
Commit #18b2859d2522a4866c398b9a32ebc3de4ec79389 broke numericality validation of virtual attributes in ActiveRecord models. This commit added a `column_type` method that assumes if `columns_hash` is a thing then our attribute would be present within it. This is not true for virtual attributes and leads to: ``` NoMethodError: undefined method `type' for nil:NilClass # /Users/bdmac/.gem/ruby/2.2.2/gems/shoulda-matchers-3.0.1/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb:442:in # `column_type' ``` This adds a check to `column_type` to return nil instead of throwing an exception if a specified attribute does not exist in the `columns_hash` because it is virtual.
- Loading branch information
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters