Sha256: f1d7881833e544c9b652f297f028f7cfcb9939b871013700f5b6608f444203fc

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

class Grandstand::Gallery < ActiveRecord::Base
  set_table_name :grandstand_galleries
  before_save :set_url
  belongs_to :user
  default_scope order('published, position, id ASC')
  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

1 entries across 1 versions & 1 rubygems

Version Path
grandstand-0.3.0 app/models/grandstand/gallery.rb