Skip to content

Instantly share code, notes, and snippets.

@tienshunlo
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tienshunlo/2d424c2a95fd9a0904de to your computer and use it in GitHub Desktop.
Save tienshunlo/2d424c2a95fd9a0904de to your computer and use it in GitHub Desktop.
surveysays
class Answer < ActiveRecord::Base
belongs_to :question
end
class Question < ActiveRecord::Base
belongs_to :survey
has_many :answers, :dependent => :destroy
accepts_nested_attributes_for :answers, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true
end
class Questionnaire < ActiveRecord::Base
has_many :questions, :dependent => :destroy
accepts_nested_attributes_for :questions, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true
end
class Survey < ActiveRecord::Base
has_many :questions, :dependent => :destroy
accepts_nested_attributes_for :questions, :reject_if => lambda { |a| a[:content].blank? }, :allow_destroy => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment