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.60.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.59.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.58.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.57.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.56.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.55.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.54.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.53.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.52.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.51.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.50.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.49.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.48.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.45.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.44.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.43.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.42.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.41.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.40.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.39.pre app/models/cmor/testimonials/category.rb