Do no use string in if conditional

Passing string to be evaluated in :if and :unless conditional options is
not supported. Pass a symbol for an instance method, or a lambda, proc
or block, instead.
This commit is contained in:
Ana María Martínez Gómez 2019-05-16 17:07:05 +02:00 committed by Henne Vogelsang
parent 254d8cb9fd
commit af1d5e4a3b
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0

View file

@ -10,7 +10,7 @@ class SurveyQuestion < ActiveRecord::Base
ICONS = { boolean: 'dot-circle-o', choice: 'check-square-o', string: 'edit', text: 'align-left', datetime: 'clock-o', numeric: 'slack' }.freeze
validates :title, presence: true
validates :possible_answers, :max_choices, :min_choices, presence: true, if: 'choice?'
validates :possible_answers, :max_choices, :min_choices, presence: true, if: :choice?
validates :min_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true
validates :max_choices, numericality: { greater_than_or_equal_to: 1 }, allow_blank: true