Sha256: 60515ae8f9ba6c48fadd271d6abfac36a6be3c3f1d2518f22233b1b748f83c26

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

class Skyline::Sections::LinkSection < ActiveRecord::Base
  include Skyline::SectionItem
  include NestedAttributesPositioning  
  
  has_many :links, :class_name => "Skyline::LinkSectionLink", :dependent => :destroy
  
  validate :has_at_least_one_link
  
  accepts_nested_attributes_for :links, :allow_destroy => true
  
  def clone
    returning super do |clone|
      clone.links = self.links.collect{|link| link.clone}
    end
  end  
  
  protected
  def has_at_least_one_link
    self.errors.add(:links, :no_links) unless self.links.detect{|link| !link.marked_for_destruction?}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skylinecms-3.0.7 app/models/skyline/sections/link_section.rb