Newer
Older
dmpopidor / app / models / section.rb
class Section < ActiveRecord::Base

  ##
  # Associations
  belongs_to :phase
  belongs_to :organisation
  has_many :questions, :dependent => :destroy

  #Link the data
  accepts_nested_attributes_for :questions, :reject_if => lambda {|a| a[:text].blank? },  :allow_destroy => true
#  accepts_nested_attributes_for :version

  attr_accessible :organisation_id, :description, :number, :title, :published, 
                  :questions_attributes, :organisation, :phase, :modifiable,
                  :as => [:default, :admin]
                  
  validates :phase, :title, :number, presence: true
  
  ##
  # return the title of the section
  #
  # @return [String] the title of the section
  def to_s
    "#{title}"
  end

# TODO: Commented this amoeba cloning gem definition out to see if its even used. The
#       amoeba documentations uses [object].amoeba_dup to clone the object, but that
#       command does not exist in the codebase
#  amoeba do
#    include_association :questions
#  end

end