Sha256: 7c8e78343db1de73b07e839ac7de37c0debd76a6cd72a956caf640620df0b786

Contents?: true

Size: 654 Bytes

Versions: 2

Compression:

Stored size: 654 Bytes

Contents

module Elabs
  class Language < ApplicationRecord
    self.table_name = 'languages'

    validates :iso639_1, presence: true
    validates :name,     presence: true

    has_many :albums
    has_many :articles
    has_many :notes
    has_many :projects
    has_many :uploads

    scope :with_content_only, -> { where.not(albums_count: 0).or(where.not(articles_count: 0)).or(where.not(notes_count: 0)).or(where.not(projects_count: 0)).or(where.not(uploads_count: 0)) }
    scope :available_site_translations, -> { select(:id, :name, :iso639_1).where(iso639_1: I18n.available_locales) }
    scope :for_list, -> { order(:name).pluck(:name, :id) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elabs-3.0.0 app/models/elabs/language.rb
elabs-2.0.0 app/models/elabs/language.rb