Class: Rapidfire::Questions::Numeric
- Inherits:
-
Rapidfire::Question
- Object
- ApplicationRecord
- Rapidfire::Question
- Rapidfire::Questions::Numeric
- Defined in:
- app/models/rapidfire/questions/numeric.rb
Instance Method Summary collapse
Methods inherited from Rapidfire::Question
inherited, #rules, #type_can_change, #validation_rules=
Instance Method Details
#validate_answer(answer) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/rapidfire/questions/numeric.rb', line 4 def validate_answer(answer) super(answer) if rules[:presence] == "1" || answer.answer_text.present? gt_or_lt = {} if rules[:greater_than_or_equal_to].present? gt_or_lt[:greater_than_or_equal_to] = rules[:greater_than_or_equal_to].to_i end if rules[:less_than_or_equal_to].present? gt_or_lt[:less_than_or_equal_to] = rules[:less_than_or_equal_to].to_i end answer.validates_numericality_of :answer_text, gt_or_lt end end |