Skip to content

Commit 55507cf

Browse files
committed
Merge pull request svenfuchs#40 from pawelnguyen/rails-4
Rails 4 compatibility
2 parents 22b1f76 + 7492c42 commit 55507cf

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/i18n/backend/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def store_translations(locale, data, options = {})
3131

3232
def lookup(locale, key, scope = [], options = {})
3333
key = normalize_flat_keys(locale, key, scope, options[:separator])
34-
result = Translation.locale(locale).lookup(key).all
34+
result = Translation.locale(locale).lookup(key)
3535

3636
if result.empty?
3737
nil

lib/i18n/backend/active_record/translation.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ class Translation < ::ActiveRecord::Base
4949
TRUTHY_CHAR = "\001"
5050
FALSY_CHAR = "\002"
5151

52-
set_table_name 'translations'
53-
attr_protected :is_proc, :interpolations
52+
self.table_name = 'translations'
5453

5554
serialize :value
5655
serialize :interpolations, Array
5756

5857
class << self
5958
def locale(locale)
60-
scoped(:conditions => { :locale => locale.to_s })
59+
where(:locale => locale.to_s)
6160
end
6261

6362
def lookup(keys, *separator)
@@ -70,11 +69,11 @@ def lookup(keys, *separator)
7069
end
7170

7271
namespace = "#{keys.last}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%"
73-
scoped(:conditions => ["#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace])
72+
where("#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace)
7473
end
7574

7675
def available_locales
77-
Translation.find(:all, :select => 'DISTINCT locale').map { |t| t.locale.to_sym }
76+
Translation.distinct(:locale).map { |t| t.locale.to_sym }
7877
end
7978
end
8079

0 commit comments

Comments
 (0)