Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

don't use i18n just with attribute to lookup translation if it is a model #368

Merged
merged 2 commits into from

3 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 2 deletions.
  1. +1 −1  lib/simple_form/inputs/base.rb
  2. +10 −1 test/form_builder/hint_test.rb
View
2  lib/simple_form/inputs/base.rb
@@ -129,7 +129,7 @@ def translate(namespace, default='')
lookups << :"#{joined_model_names}.#{lookup_action}.#{reflection_or_attribute_name}"
lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}"
end
- lookups << :"#{reflection_or_attribute_name}"
+ lookups << :"#{attribute_name}" unless reflection
lookups << default
I18n.t(lookups.shift, :scope => :"simple_form.#{namespace}", :default => lookups).presence
View
11 test/form_builder/hint_test.rb
@@ -79,6 +79,15 @@ def with_hint_for(object, *args)
end
end
+ test 'hint should not use i18n just with attribute to lookup translation if it is a model' do
+ store_translations(:en, :simple_form => { :hints => {
+ :company => { :name => 'Nome' }
+ } } ) do
+ with_hint_for @user, :company, :reflection => Association.new(Company, :company, {})
+ assert_no_select 'span.hint'
+ end
+ end
+
test 'hint should use i18n just with attribute to lookup translation' do
store_translations(:en, :simple_form => { :hints => {
:name => 'Content of this input will be downcased...'
@@ -112,4 +121,4 @@ def with_hint_for(object, *args)
assert_select 'span.omg_hint', "can't be blank"
end
end
-end
+end
Something went wrong with that request. Please try again.