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