my application uses dates lot. lot of ajax calls , urls involve datetimes , find typical format '1920-10-10 18:30:00' unfriendly these purposes. work around creating helper method strips unnecessary characters out of date (192010101830) , method converting string in date object.
when build url goes this:
=link_to "send date", thing_my_date_path(date_to_string(datetime.now)) then when thing_date action receives, converts parameter in datetime object
def my_date @date = string_to_date(params[:mydate]) .... end this works fine in development. open other suggestions.
the problem when go test application. tests fail because helper methods date_to_string , string_to_date not present. include them in tests feel should kept separate.
so i'm looking for
a) better way pass dates around, , more importantly
b) method of testing action dependent on helper methods.
there built-in methods methinks.
> datetime.now.to_s(:number) => "20110429162748" > datetime.parse("20110429162748") => fri, 29 apr 2011 16:27:48 +0000 hope helps..
Comments
Post a Comment