Sha256: a14a17b861d056abe5036e4ae8e7252fef22a083222246b16912831f796c92b8

Contents?: true

Size: 684 Bytes

Versions: 3

Compression:

Stored size: 684 Bytes

Contents

class Carousel::Carousel < ActiveRecord::Base
  
  self.table_name = :carousel_carousels
  
  # -- Relationships --------------------------------------------------------
  has_many :slides,
    :dependent => :destroy
    
  # -- Validations ----------------------------------------------------------
  validates :label,
    :presence => true
  validates :identifier,
    :presence => true,
    :format   => { :with => /^\w[a-z0-9_-]*$/i }
    
  # -- Callbacks ------------------------------------------------------------
  before_validation :assign_label
  
protected
  
  def assign_label
    self.label = self.label.blank?? self.identifier.try(:titleize) : self.label
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfy_carousel-0.0.3 app/models/carousel/carousel.rb
comfy_carousel-0.0.2 app/models/carousel/carousel.rb
comfy_carousel-0.0.1 app/models/carousel/carousel.rb