Set Poll.multi_select_count to default value in model if nil
Since multi_select_count depends on the type of poll, we can not require its presence via validates_presence_of, but can use the default value.
This commit is contained in:
parent
b089b7c186
commit
d75b881318
1 changed files with 4 additions and 0 deletions
|
@ -23,6 +23,10 @@ class Poll < ActiveRecord::Base
|
|||
include DateTimeAttributeValidate
|
||||
date_time_attribute :starts, :ends
|
||||
|
||||
before_save do
|
||||
self.multi_select_count ||= 0
|
||||
end
|
||||
|
||||
def available_points
|
||||
return 0...0 if min_points.nil? || max_points.nil?
|
||||
min_points..max_points
|
||||
|
|
Loading…
Reference in a new issue