Sha256: eeec19abdb9a79eb81fcb238cf8661fddb23e66ae5d729b34eb942dd0ff8474a
Contents?: true
Size: 734 Bytes
Versions: 1
Compression:
Stored size: 734 Bytes
Contents
class Carousel::Slide < ActiveRecord::Base self.table_name = :carousel_slides has_attached_file :file # -- Relationships -------------------------------------------------------- belongs_to :carousel # -- Callbacks ------------------------------------------------------------ before_create :assign_position # -- Validations ---------------------------------------------------------- validates :carousel_id, :label, :presence => true # -- Scopes --------------------------------------------------------------- default_scope order('carousel_slides.position') protected def assign_position max = carousel.slides.maximum(:position) self.position = max ? max + 1 : 0 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfy_carousel-0.0.1 | app/models/carousel/slide.rb |