I tend to think that to be a dangerous approach. Overriding a core
method like parse may affect any number of rails plugins, core rails
code and your own code, which may not be aware of this change.
You can probably vouch for your own code, if your the only one writing
it, but if it needs to be supported by someone else, then things can
get messy.
It's not clear on your reasoning for not just using the optional
second argument when you are calling Date.parse, but I'm sure there is
a good one. So I can only suggest making a specialised version of the
method. If you don't like the default arguments and you don't want to
pass the argument, I'd recommend writing another method that assumes
the value of that argument. eg.
class Date
def self.parse_modern(str, *args)
return parse(str, args.unshift(true))
end
end
That leaves all plugins/libraries/legacy code happily using
Date.parse. You can now start using Date.parse_modern(str). Of
course, assuming you don't want to just use Date.parse(str, true).
Where to put it? Don't know whether application_helper.rb is quite
the place to put it. You've changed a library that is accessible to
the entire rails stack, so loading it in a helper sounds misleading.
I'd recommend writing it in lib/ and loading it when rails boots.
Then there's no question as to which version the entire rails app
sees.
Well that's some thoughts anyway. Hope it's a worthwhile read.
Kim