Sha256: d5c65b23450563a863d25b7359d5038c89eb76f900576ccd5608bbe6845c873b

Contents?: true

Size: 504 Bytes

Versions: 2

Compression:

Stored size: 504 Bytes

Contents

class Grandstand::Gallery < ActiveRecord::Base
  before_save :set_url
  belongs_to :user
  default_scope order('position, id')
  has_many :images, :dependent => :destroy

  validates_presence_of :name, :message => 'Your gallery needs a name'
  validates_uniqueness_of :name, :message => 'A gallery with that name already exists'

  def cover_image
    images.first || Grandstand::Image.new
  end

  # def to_param
  #   url
  # end

  protected
  def set_url
    self.url ||= name.parameterize
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grandstand-0.2.7 app/models/grandstand/gallery.rb
grandstand-0.2.6 app/models/grandstand/gallery.rb