Make answers translatable
This commit is contained in:
@@ -9,7 +9,9 @@ class Poll::Answer < ActiveRecord::Base
|
||||
validates :author, presence: true
|
||||
validates :answer, presence: true
|
||||
|
||||
validates :answer, inclusion: { in: ->(a) { a.question.question_answers.pluck(:title) }},
|
||||
validates :answer, inclusion: { in: ->(a) { a.question.question_answers
|
||||
.joins(:translations)
|
||||
.pluck("poll_question_answer_translations.title") }},
|
||||
unless: ->(a) { a.question.blank? }
|
||||
|
||||
scope :by_author, ->(author_id) { where(author_id: author_id) }
|
||||
|
||||
@@ -10,7 +10,9 @@ class Poll::PartialResult < ActiveRecord::Base
|
||||
validates :question, presence: true
|
||||
validates :author, presence: true
|
||||
validates :answer, presence: true
|
||||
validates :answer, inclusion: { in: ->(a) { a.question.question_answers.pluck(:title) }},
|
||||
validates :answer, inclusion: { in: ->(a) { a.question.question_answers
|
||||
.joins(:translations)
|
||||
.pluck("poll_question_answer_translations.title") }},
|
||||
unless: ->(a) { a.question.blank? }
|
||||
validates :origin, inclusion: { in: VALID_ORIGINS }
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
class Poll::Question::Answer < ActiveRecord::Base
|
||||
include Galleryable
|
||||
include Documentable
|
||||
|
||||
translates :title, touch: true
|
||||
translates :description, touch: true
|
||||
globalize_accessors locales: [:en, :es, :fr, :nl, :pt_br]
|
||||
|
||||
documentable max_documents_allowed: 3,
|
||||
max_file_size: 3.megabytes,
|
||||
accepted_content_types: [ "application/pdf" ]
|
||||
@@ -15,7 +20,7 @@ class Poll::Question::Answer < ActiveRecord::Base
|
||||
before_validation :set_order, on: :create
|
||||
|
||||
def description
|
||||
super.try :html_safe
|
||||
self[:description].try :html_safe
|
||||
end
|
||||
|
||||
def self.order_answers(ordered_array)
|
||||
|
||||
Reference in New Issue
Block a user