Remove before validation callback
This was breaking nested poll_questions_answers when submitting more than one new answer at a time.
This commit is contained in:
@@ -17,8 +17,6 @@ class Poll::Question::Answer < ActiveRecord::Base
|
||||
validates :title, presence: true
|
||||
validates :given_order, presence: true, uniqueness: { scope: :question_id }
|
||||
|
||||
before_validation :set_order, on: :create
|
||||
|
||||
def description
|
||||
self[:description].try :html_safe
|
||||
end
|
||||
@@ -29,10 +27,6 @@ class Poll::Question::Answer < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def set_order
|
||||
self.given_order = self.class.last_position(question_id) + 1
|
||||
end
|
||||
|
||||
def self.last_position(question_id)
|
||||
where(question_id: question_id).maximum('given_order') || 0
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user