From 7492c425cc30a5427f3d1847896a9d014164e2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nguyen?= Date: Wed, 18 Sep 2013 10:36:07 +0200 Subject: [PATCH] Rails 4 compatibility --- lib/i18n/backend/active_record.rb | 2 +- lib/i18n/backend/active_record/translation.rb | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/i18n/backend/active_record.rb b/lib/i18n/backend/active_record.rb index b90d21ae..a5c2082f 100644 --- a/lib/i18n/backend/active_record.rb +++ b/lib/i18n/backend/active_record.rb @@ -31,7 +31,7 @@ def store_translations(locale, data, options = {}) def lookup(locale, key, scope = [], options = {}) key = normalize_flat_keys(locale, key, scope, options[:separator]) - result = Translation.locale(locale).lookup(key).all + result = Translation.locale(locale).lookup(key) if result.empty? nil diff --git a/lib/i18n/backend/active_record/translation.rb b/lib/i18n/backend/active_record/translation.rb index 8f8f6f49..d5d29296 100644 --- a/lib/i18n/backend/active_record/translation.rb +++ b/lib/i18n/backend/active_record/translation.rb @@ -49,15 +49,14 @@ class Translation < ::ActiveRecord::Base TRUTHY_CHAR = "\001" FALSY_CHAR = "\002" - set_table_name 'translations' - attr_protected :is_proc, :interpolations + self.table_name = 'translations' serialize :value serialize :interpolations, Array class << self def locale(locale) - scoped(:conditions => { :locale => locale.to_s }) + where(:locale => locale.to_s) end def lookup(keys, *separator) @@ -70,11 +69,11 @@ def lookup(keys, *separator) end namespace = "#{keys.last}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%" - scoped(:conditions => ["#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace]) + where("#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace) end def available_locales - Translation.find(:all, :select => 'DISTINCT locale').map { |t| t.locale.to_sym } + Translation.distinct(:locale).map { |t| t.locale.to_sym } end end