Sha256: 1b92e8a80b304c81ad323b45846467d299486ad72a56ee7df5e218c3157c34b0

Contents?: true

Size: 676 Bytes

Versions: 24

Compression:

Stored size: 676 Bytes

Contents

module Tolk
  class Phrase < ActiveRecord::Base
    self.table_name = "tolk_phrases"

    validates_uniqueness_of :key

    paginates_per 30

    has_many :translations, :class_name => 'Tolk::Translation', :dependent => :destroy do
      def primary
        to_a.detect {|t| t.locale_id == Tolk::Locale.primary_locale.id}
      end

      def for(locale)
        to_a.detect {|t| t.locale_id == locale.id}
      end
    end

    attr_accessor :translation

#scope :red, -> { where(color: 'red') } rather than scope :red, -> { { conditions: { color: 'red' } } }

    scope :containing_text, lambda { |query|
      where("tolk_phrases.key LIKE ?", "%#{query}%")
    }
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
tolk-6.0.0 app/models/tolk/phrase.rb
tolk-6.0.0.alpha1 app/models/tolk/phrase.rb
tolk-5.0.2 app/models/tolk/phrase.rb
tolk-5.0.1 app/models/tolk/phrase.rb
tolk-5.0.0 app/models/tolk/phrase.rb
tolk-4.3.0 app/models/tolk/phrase.rb
tolk-4.2.0 app/models/tolk/phrase.rb
tolk-4.1.1 app/models/tolk/phrase.rb
tolk-4.1.0 app/models/tolk/phrase.rb
tolk-4.0.1 app/models/tolk/phrase.rb
tolk-4.0.0 app/models/tolk/phrase.rb
tolk-3.2.1 app/models/tolk/phrase.rb
tolk-3.2.0 app/models/tolk/phrase.rb
tolk-3.1.0 app/models/tolk/phrase.rb
tolk-3.0.2 app/models/tolk/phrase.rb
tolk-3.0.1 app/models/tolk/phrase.rb
tolk-3.0.0 app/models/tolk/phrase.rb
tolk-2.0.0 app/models/tolk/phrase.rb
tolk-1.9.3 app/models/tolk/phrase.rb
tolk-1.8.1 app/models/tolk/phrase.rb