Skip to content
This repository
Browse code

remove call to self.locale from helpers

  • Loading branch information...
commit c178a87b4326edd491922136c0a55bf4b889473d 1 parent 2ee9f2a
Sven Fuchs authored June 23, 2008
5  actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -159,9 +159,6 @@ def error_messages_for(*params)
159 159
         end
160 160
         
161 161
         count  = objects.inject(0) {|sum, object| sum + object.errors.count }
162  
-        locale = options[:locale]
163  
-        locale ||= self.locale if respond_to?(:locale)
164  
-
165 162
         unless count.zero?
166 163
           html = {}
167 164
           [:id, :class].each do |key|
@@ -174,7 +171,7 @@ def error_messages_for(*params)
174 171
           end
175 172
           options[:object_name] ||= params.first
176 173
 
177  
-          I18n.with_options :locale => locale, :scope => [:active_record, :error] do |locale|
  174
+          I18n.with_options :locale => options[:locale], :scope => [:active_record, :error] do |locale|
178 175
             header_message = if options.include?(:header_message)
179 176
               options[:header_message]
180 177
             else 
5  actionpack/lib/action_view/helpers/date_helper.rb
@@ -59,15 +59,12 @@ module DateHelper
59 59
       #   distance_of_time_in_words(Time.now, Time.now)           # => less than a minute
60 60
       #
61 61
       def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
62  
-        locale = options[:locale] 
63  
-        locale ||= self.locale if respond_to?(:locale)
64  
-
65 62
         from_time = from_time.to_time if from_time.respond_to?(:to_time)
66 63
         to_time = to_time.to_time if to_time.respond_to?(:to_time)
67 64
         distance_in_minutes = (((to_time - from_time).abs)/60).round
68 65
         distance_in_seconds = ((to_time - from_time).abs).round
69 66
 
70  
-        I18n.with_options :locale => locale, :scope => :'datetime.distance_in_words' do |locale|
  67
+        I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
71 68
           case distance_in_minutes
72 69
             when 0..1
73 70
               return distance_in_minutes == 0 ? 
9  actionpack/lib/action_view/helpers/number_helper.rb
@@ -69,12 +69,9 @@ def number_to_phone(number, options = {})
69 69
       #  number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u")
70 70
       #  # => 1234567890,50 £
71 71
       def number_to_currency(number, options = {})
72  
-        options = options.symbolize_keys
73  
-
74  
-        locale = options[:locale]
75  
-        locale ||= self.locale if respond_to?(:locale)
76  
-
77  
-        defaults  = :'currency.format'.t(locale) || {}
  72
+        options  = options.symbolize_keys
  73
+        defaults = :'currency.format'.t(options[:locale]) || {}
  74
+                
78 75
         precision = options[:precision] || defaults[:precision]
79 76
         unit      = options[:unit]      || defaults[:unit]
80 77
         separator = options[:separator] || defaults[:separator]

0 notes on commit c178a87

Please sign in to comment.
Something went wrong with that request. Please try again.