lib/active_record_extensions.rb

require 'i18n'
require 'active_record_extensions/time_parser'
ActiveRecord::Base.send(:include, ActiveRecordExtensions::TimeParser)

lib/active_record_extensions/time_parser.rb

module ActiveRecordExtensions
  module TimeParser
    def self.included(base)
      base.extend(ClassMethods)
    end
    module ClassMethods
      # add your static(class) methods here
      def datepicker_attributes(*args)
        options = args.extract_options!
        args.delete_at(-1) if args[-1].is_a?(Hash)
        args.each do |arg|
          column_type = self.columns_hash[arg.to_s].type
          raise StandardError, "Wrong column declaration, specify a 
column with date or datetime type" if column_type != :date && 
column_type != :datetime
          define_method "#{arg.to_s}=" do |date|
            aux_date = nil
## FIXME: NEVER ENTERS INSIDE THAT LOOP I18n.t...
            I18n.t('time.datepicker_formats').values do |format|
              aux_date = Time.strptime(date, format) rescue nil
              break unless aux_date.nil?
            end
            write_attribute(arg.to_sym,aux_date || date)
          end
        end
      end
   end
  end
end



config/locales/en/model:

en:
  time:
    datepicker_formats:
      default: "%d/%m/%Y %H:%M"

config/environment.rb:

require "active_record_extensions"