Last active
January 24, 2016 17:06
-
-
Save aldesantis/f48a6889a0088d2dba48 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Model < ActiveRecord::Base | |
| validate :validate_multiples | |
| private | |
| def validate_multiples | |
| %w(attribute1 attribute2 attribute3).each do |attribute| | |
| value = send(attribute) | |
| next if value.blank? | |
| next if value % 0.5 == 0 | |
| errors.add attribute, 'is not a multiple of 0.5' | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment