Sha256: 0fc6d75108d02101947f9823ebf4d1d86a7d0953b86674208b560dcf795f1e8f

Contents?: true

Size: 692 Bytes

Versions: 49

Compression:

Stored size: 692 Bytes

Contents

module Cmor
  module Testimonials
    class Category < ActiveRecord::Base
      has_many :testimonials, -> { order(position: :asc) }, dependent: :destroy do
        def published 
          merge(Testimonial.published)
        end
      end

      scope :with, ->(type) { joins(type) }
      scope :with_published_testimonials, -> { with(:testimonials).merge(Testimonial.published) }

      validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
      validates :identifier, presence: true, uniqueness: { scope: [ :locale ] }
      validates :name, presence: true, uniqueness: { scope: [ :locale ] }

      def human
        name
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
cmor_testimonials-0.0.38.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.37.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.36.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.35.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.34.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.33.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.32.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.31.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.30.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.29.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.28.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.27.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.26.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.25.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.24.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.22.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.21.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.20.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.19.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.18.pre app/models/cmor/testimonials/category.rb