Sha256: a37d17c6c47e86351c0f7559ddc9328fa8c42d21c3a42d991a9ecf8456983aee
Contents?: true
Size: 689 Bytes
Versions: 25
Compression:
Stored size: 689 Bytes
Contents
module Pulitzer class FreeFormSection < ActiveRecord::Base belongs_to :version belongs_to :free_form_section_type has_many :partials, -> { order :sort_order} delegate :sort_order, to: :free_form_section_type, allow_nil: true def partial(name) self.partials.to_a.detect{|ffs| ffs.name == name} end def clone_me clone_attrs = self.attributes.dup clone_attrs.delete 'id' clone_attrs.delete 'version_id' my_clone = Pulitzer::FreeFormSection.create!(clone_attrs) partials.each do |partial| cloned_partial = partial.clone_me my_clone.partials << cloned_partial end my_clone end end end
Version data entries
25 entries across 25 versions & 1 rubygems