Sha256: 13905e9da8a17f9e457c2daea7ba7e6839009fd9643cec475c03405d66467dda

Contents?: true

Size: 743 Bytes

Versions: 16

Compression:

Stored size: 743 Bytes

Contents

module Concerns::Album
  extend ActiveSupport::Concern

  included do
    extend Enumerize
    extend FriendlyId

    attr_accessible :date, :description, :status, :title

    enumerize :status, in: [:published, :unpublished], default: :published, predicates: true
    friendly_id :title, use: :slugged

    has_many :photos, dependent: :destroy
    belongs_to :related, :polymorphic => true

    validation_for_title
    validation_for_date


    scope :published, includes(:photos).where(status: :published)

    scope :desc, order('albums.date DESC')

  end

  module ClassMethods
    
    def validation_for_title
      validates_presence_of :title
    end

    def validation_for_date
      validates_presence_of :date
    end

  end

end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
mix-rails-0.26.3 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.26.3 app/models/concerns/album.rb
mix-rails-0.26.2 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.26.2 app/models/concerns/album.rb
mix-rails-0.26.1 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.26.1 app/models/concerns/album.rb
mix-rails-0.26.0 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.26.0 app/models/concerns/album.rb
mix-rails-0.25.1 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.25.1 app/models/concerns/album.rb
mix-rails-0.25.0 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.25.0 app/models/concerns/album.rb
mix-rails-0.24.1 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.24.1 app/models/concerns/album.rb
mix-rails-0.24.0 mix-rails-albums/app/models/concerns/album.rb
mix-rails-albums-0.24.0 app/models/concerns/album.rb