Merge pull request #213 from piton/translate-common-attributes

I18n common attributes and Translate.attribute_name
This commit is contained in:
jonatack 2013-05-23 14:56:48 +02:00
parent 1b9bbb8dcf
commit f536007960
3 changed files with 15 additions and 6 deletions

View File

@ -68,11 +68,12 @@ module Ransack
:"ransack.attributes.#{associated_class.model_name.singular}.#{attr_name}" : :"ransack.attributes.#{associated_class.model_name.singular}.#{attr_name}" :
:"ransack.attributes.#{context.klass.model_name.singular}.#{attr_name}" :"ransack.attributes.#{context.klass.model_name.singular}.#{attr_name}"
), ),
:default => [ default: [
(associated_class ? (associated_class ?
:"#{associated_class.i18n_scope}.attributes.#{associated_class.model_name.singular}.#{attr_name}" : :"#{associated_class.i18n_scope}.attributes.#{associated_class.model_name.singular}.#{attr_name}" :
:"#{context.klass.i18n_scope}.attributes.#{context.klass.model_name.singular}.#{attr_name}" :"#{context.klass.i18n_scope}.attributes.#{context.klass.model_name.singular}.#{attr_name}"
), ),
:".attributes.#{attr_name}",
attr_name.humanize attr_name.humanize
] ]
) )

View File

@ -48,11 +48,17 @@ module Ransack
end end
describe '#sort_link' do 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 'sort_link for common attribute' do
it { should match /sort_link/} sort_link = @f.sort_link :id, :controller => 'people'
it { should match /Full Name<\/a>/} sort_link.should match /id<\/a>/
end
end end
describe '#submit' do describe '#submit' do

View File

@ -1,4 +1,6 @@
en: en:
attributes:
id: 'id'
ransack: ransack:
attributes: attributes:
person: person: