Sam Donaldson
2006-May-13 21:40 UTC
[Rails] undefined method `strftime'', being called from a partial.
Hi,
I''m having an issue with calling a function that I''ve defined
in
ApplicationHelper called format_time:
module ApplicationHelper
def format_time(time)
time.strftime("%a %b %d, %I:%M%p")
end
end
I use this function in my views to format the Time.now that I would have
stored in my tables as a DATETIME. I''m able to use this function,
without
any issues from my views, but if I try using it from a partial, I guess the
following error:
undefined method `strftime'' for "2006-05-12 21:31:48":String
I guess the problem is that the time is coming in as a String into
format_time, when it should be of type Time.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060513/11c64cfa/attachment.html
Daniel Higginbotham
2006-May-13 21:50 UTC
[Rails] undefined method `strftime'', being called from a partial.
Try
require ''parsedate''
new_time = Time.local(ParseDate.parsedate(time))
new_time.strftime()
Daniel
_____
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Sam Donaldson
Sent: Saturday, May 13, 2006 11:41 AM
To: rails@lists.rubyonrails.org
Subject: [Rails] undefined method `strftime'', being called from a
partial.
Hi,
I''m having an issue with calling a function that I''ve defined
in
ApplicationHelper called format_time:
module ApplicationHelper
def format_time(time)
time.strftime("%a %b %d, %I:%M%p")
end
end
I use this function in my views to format the Time.now that I would have
stored in my tables as a DATETIME. I''m able to use this function,
without
any issues from my views, but if I try using it from a partial, I guess the
following error:
undefined method `strftime'' for "2006-05-12 21:31:48":String
I guess the problem is that the time is coming in as a String into
format_time, when it should be of type Time.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060513/45b71863/attachment-0001.html