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.17.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.16.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.15.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.14.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.13.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.12.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.11.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.10.pre app/models/cmor/testimonials/category.rb
cmor_testimonials-0.0.9.pre app/models/cmor/testimonials/category.rb