uses new answer model in user facing interface

This commit is contained in:
rgarcia
2017-10-04 17:45:51 +02:00
parent 461410a79d
commit 4aaf681d2d
8 changed files with 28 additions and 20 deletions

View File

@@ -8,8 +8,10 @@ class Poll::Answer < ActiveRecord::Base
validates :question, presence: true
validates :author, presence: true
validates :answer, presence: true
validates :answer, inclusion: { in: ->(a) { a.question.valid_answers }},
unless: ->(a) { a.question.blank? }
# temporary skipping validation, review when removing valid_answers
# validates :answer, inclusion: { in: ->(a) { a.question.valid_answers }},
# unless: ->(a) { a.question.blank? }
scope :by_author, ->(author_id) { where(author_id: author_id) }
scope :by_question, ->(question_id) { where(question_id: question_id) }