Migrate registration attributes to questions
This commit is contained in:
parent
08a47339a4
commit
59f2b636c5
9 changed files with 401 additions and 15 deletions
|
|
@ -5,4 +5,6 @@ class Qanswer < ActiveRecord::Base
|
|||
belongs_to :answer, dependent: :delete
|
||||
|
||||
has_and_belongs_to_many :registrations
|
||||
|
||||
validates :question, :answer, presence: true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,8 +7,13 @@ class Question < ActiveRecord::Base
|
|||
has_many :qanswers, dependent: :delete_all
|
||||
has_many :answers, through: :qanswers, dependent: :delete_all
|
||||
|
||||
validates :title, presence: true
|
||||
validates :answers, presence: true
|
||||
|
||||
validates :title, :question_type_id, presence: true
|
||||
validate :existing_answers
|
||||
accepts_nested_attributes_for :answers, allow_destroy: true
|
||||
|
||||
private
|
||||
|
||||
def existing_answers
|
||||
errors.add(:base, 'The question must have answers') if self.answers.blank?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,10 +11,8 @@ class Registration < ActiveRecord::Base
|
|||
has_many :events_registrations
|
||||
has_many :workshops, through: :events_registrations, source: :event
|
||||
|
||||
attr_accessible :user_id, :conference_id, :attending_social_events, :attending_with_partner,
|
||||
:using_affiliated_lodging, :arrival, :departure, :user_attributes, :attended,
|
||||
:other_dietary_choice, :dietary_choice_id, :handicapped_access_required,
|
||||
:social_event_ids, :other_special_needs,
|
||||
attr_accessible :user_id, :conference_id, :arrival, :departure, :user_attributes, :attended,
|
||||
:other_dietary_choice, :dietary_choice_id, :social_event_ids, :other_special_needs,
|
||||
:event_ids, :volunteer, :vchoice_ids, :qanswer_ids, :qanswers_attributes
|
||||
|
||||
accepts_nested_attributes_for :user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue