Topic: Custom lib and I18n.t()

Hi there,I'm doing an own library to manage datetimes depending on locales, todeal with the formats of datetimes. I actually overrides the defaultassign methods to made strptime.

I've made the following code:

http://ideone.com/PXYl8

something is wrong when doing I18n.t('time.datepicker_formats').values. It's never entering inside that loop (I've put a debugger inside it).

## Never enters inside that loop!!

I18n.translate('time.datepicker_formats').values do |format|
              require 'ruby-debug';debugger;1
              aux_date = Time.strptime(date, format) rescue nil
              break unless aux_date.nil?
end
###

if I put a debugger outside that misterious loop it prints what is expected...console output:
1.9.3p125 :001 > User.datepicker_attributes :created_at
=> [:created_at]
1.9.3p125 :002 > User.new.created_at = "10/10/2012 10:12"
=> "10/10/2012 10:12"
1.9.3p125 :003 > I18n.t('time.datepicker_formats')
=> {:default=>"%d/%m/%Y %H:%M"}
1.9.3p125 :004 > I18n.t('time.datepicker_formats').values
=> ["%d/%m/%Y %H:%M"]

Someone know what's missing?

Last edited by gvidal (2012-04-30 14:15:10)