1

I have put a small monkey patch to allow for better String.to_date handling. It works great on strings but it seems mongoid has its own method for trying to convert the string into a date. I am doing this because ruby expects a "DD/MM/YY" where my monkey patch will allow for any localized date format and covert it to a Date object.

I need to do a similar monkey patch to Mongoid.

app/config/initializers/string_to_date_monkey_match.rb

class String
  def to_date
    Chronic.parse(self).to_date
  end
end
Jason Waldrip
  • 5,038
  • 8
  • 36
  • 59

1 Answers1

1

You should look into the home_run gem. It lets you specify a default time format

Mike
  • 364
  • 1
  • 9