Sha256: 312ba86c6777455229fdcfafdb1fbb900e6528b3ced89ded0b1f3d314074f21c
Contents?: true
Size: 777 Bytes
Versions: 8
Compression:
Stored size: 777 Bytes
Contents
class SpudPhotoGallery < ActiveRecord::Base attr_accessible :title, :url_name, :albums, :album_ids has_many :spud_photo_galleries_albums, :dependent => :destroy has_many :albums, :through => :spud_photo_galleries_albums, :source => :spud_photo_album validates_presence_of :title, :url_name validates_uniqueness_of :title, :url_name before_validation :set_url_name def top_photo_url(style) unless albums.empty? return albums.first.top_photo_url(style) end end def albums_available if album_ids.any? return SpudPhotoAlbum.where('id not in (?)', album_ids) else return SpudPhotoAlbum.all end end private def set_url_name if self.title self.url_name = self.title.parameterize end end end
Version data entries
8 entries across 8 versions & 2 rubygems