Class: Cats::Core::CommoditySubstitution
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Cats::Core::CommoditySubstitution
- Defined in:
- app/models/cats/core/commodity_substitution.rb
Instance Method Summary collapse
Instance Method Details
#validate_ratio ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/cats/core/commodity_substitution.rb', line 12 def validate_ratio return unless ratio left, right = ratio.split(":") left_correct = begin Integer(left).is_a?(Integer) rescue StandardError false end right_correct = begin Integer(right).is_a?(Integer) rescue StandardError false end errors.add(:ratio, "is not in correct format.") unless left_correct && right_correct end |