diff --git a/lib/ransack/adapters/mongoid/ransack/translate.rb b/lib/ransack/adapters/mongoid/ransack/translate.rb index a6c2730..f321927 100644 --- a/lib/ransack/adapters/mongoid/ransack/translate.rb +++ b/lib/ransack/adapters/mongoid/ransack/translate.rb @@ -2,11 +2,12 @@ module Ransack module Translate def self.i18n_key(klass) - if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0 - klass.model_name.i18n_key.to_s.tr('.', '/') - else - klass.model_name.i18n_key.to_s - end + # if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0 + # klass.model_name.i18n_key.to_s.tr('.', '/') + # else + # klass.model_name.i18n_key.to_s + # end + klass.model_name.i18n_key.to_s end end end diff --git a/spec/mongoid/translate_spec.rb b/spec/mongoid/translate_spec.rb new file mode 100644 index 0000000..2ebfdf4 --- /dev/null +++ b/spec/mongoid/translate_spec.rb @@ -0,0 +1,14 @@ +require 'mongoid_spec_helper' + +module Ransack + describe Translate do + + describe '.attribute' do + it 'translate namespaced attribute like AR does' do + ar_translation = ::Namespace::Article.human_attribute_name(:title) + ransack_translation = Ransack::Translate.attribute(:title, :context => ::Namespace::Article.search.context) + expect(ransack_translation).to eq ar_translation + end + end + end +end