Merge branch 'master' into fix/shift_creation_polls
This commit is contained in:
@@ -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) }
|
||||
|
||||
@@ -14,7 +14,8 @@ class Poll::Question < ActiveRecord::Base
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
|
||||
has_many :comments, as: :commentable
|
||||
has_many :answers
|
||||
has_many :answers, class_name: 'Poll::Answer'
|
||||
has_many :question_answers, class_name: 'Poll::Question::Answer'
|
||||
has_many :partial_results
|
||||
belongs_to :proposal
|
||||
|
||||
|
||||
9
app/models/poll/question/answer.rb
Normal file
9
app/models/poll/question/answer.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Poll::Question::Answer < ActiveRecord::Base
|
||||
belongs_to :question, class_name: 'Poll::Question', foreign_key: 'question_id'
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
def description
|
||||
super.try :html_safe
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user