Sha256: 59b586e0b79b0898aa3dc45552a0a37edebf855c05ba4219d910da4ac9d79ca0
Contents?: true
Size: 1 KB
Versions: 5
Compression:
Stored size: 1 KB
Contents
module ActiveadminSelleoCms class FormAnswer < ActiveRecord::Base attr_accessible :form_uuid, :dom_id, :form_id, :form_question_id, :value, :form_answer_attachments_attributes validates_presence_of :form_uuid, :dom_id belongs_to :form belongs_to :form_question has_many :form_answer_attachments accepts_nested_attributes_for :form_answer_attachments after_save do if form_question.input_type == :radio_button_tag and !dom_id.match(/_other/) FormAnswer.where(form_uuid: form_uuid, form_question_id: form_question_id).where("id <> ? AND dom_id NOT LIKE '%_other%'", id).destroy_all end end def self.value_for(form_uuid, dom_id) if answer = self.where(form_uuid: form_uuid, dom_id: dom_id).first answer.value else nil end end def self.files_for(form_uuid, dom_id) if answer = self.where(form_uuid: form_uuid, dom_id: dom_id).first answer.form_answer_attachments else [] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems