aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers
diff options
context:
space:
mode:
authorUlisses Almeida <anizark@gmail.com>2015-02-26 18:18:58 -0300
committerUlisses Almeida <anizark@gmail.com>2015-02-26 19:04:00 -0300
commit362557eb4169a541063468b489931648665f1fa3 (patch)
tree585f548cbe42c481cd8dd70e42139a9314b00fac /actionview/lib/action_view/helpers
parent38218929e9b3205a2a731660b3c5527937e1c015 (diff)
downloadrails-362557eb4169a541063468b489931648665f1fa3.tar.gz
rails-362557eb4169a541063468b489931648665f1fa3.tar.bz2
rails-362557eb4169a541063468b489931648665f1fa3.zip
Fix regression when passing a value different of String.
The previous version of rails(4.2.0) you can pass objects to the default option of translation helper. For example: ```ruby t('foo', default: 1) ``` But on rails 4.2.1 version this kind of use stopped to work, because started only to accept String types. Now with this fix we can use orther value types on this helper again.
Diffstat (limited to 'actionview/lib/action_view/helpers')
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index 342361217c..24b633c5bb 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -37,8 +37,12 @@ module ActionView
# you know what kind of output to expect when you call translate in a template.
def translate(key, options = {})
options = options.dup
+ has_default = options.has_key?(:default)
remaining_defaults = Array(options.delete(:default))
- options[:default] = remaining_defaults.shift if remaining_defaults.first.kind_of? String
+
+ if has_default && !remaining_defaults.first.kind_of?(Symbol)
+ options[:default] = remaining_defaults.shift
+ end
# If the user has explicitly decided to NOT raise errors, pass that option to I18n.
# Otherwise, tell I18n to raise an exception, which we rescue further in this method.