diff --git a/lib/ransack/translate.rb b/lib/ransack/translate.rb index 672b117..d211339 100644 --- a/lib/ransack/translate.rb +++ b/lib/ransack/translate.rb @@ -68,11 +68,12 @@ module Ransack :"ransack.attributes.#{associated_class.model_name.singular}.#{attr_name}" : :"ransack.attributes.#{context.klass.model_name.singular}.#{attr_name}" ), - :default => [ + default: [ (associated_class ? :"#{associated_class.i18n_scope}.attributes.#{associated_class.model_name.singular}.#{attr_name}" : :"#{context.klass.i18n_scope}.attributes.#{context.klass.model_name.singular}.#{attr_name}" ), + :".attributes.#{attr_name}", attr_name.humanize ] ) diff --git a/spec/ransack/helpers/form_builder_spec.rb b/spec/ransack/helpers/form_builder_spec.rb index e52c039..2ef0c70 100644 --- a/spec/ransack/helpers/form_builder_spec.rb +++ b/spec/ransack/helpers/form_builder_spec.rb @@ -48,11 +48,17 @@ module Ransack end describe '#sort_link' do - subject { @f.sort_link :name, :controller => 'people' } + it 'sort_link for ransack attribute' do + sort_link = @f.sort_link :name, :controller => 'people' + sort_link.should match /people\?q%5Bs%5D=name\+asc/ + sort_link.should match /sort_link/ + sort_link.should match /Full Name<\/a>/ + end - it { should match /people\?q%5Bs%5D=name\+asc/} - it { should match /sort_link/} - it { should match /Full Name<\/a>/} + it 'sort_link for common attribute' do + sort_link = @f.sort_link :id, :controller => 'people' + sort_link.should match /id<\/a>/ + end end describe '#submit' do diff --git a/spec/support/en.yml b/spec/support/en.yml index 469593e..503d50c 100644 --- a/spec/support/en.yml +++ b/spec/support/en.yml @@ -1,5 +1,7 @@ en: + attributes: + id: 'id' ransack: attributes: person: - name: Full Name \ No newline at end of file + name: Full Name