Reputation: 29797
When a user logs into my site, Devise tries to update the field in the user model current_sign_in_at
with the time. But it's producing this error:
NoMethodError: undefined method `getlocal' for Mon, 08 Nov 2010 03:11:01 +0000:DateTime
[GEM_ROOT]/gems/activesupport-3.0.1/lib/active_support/time_with_zone.rb:75
I've found a couple of resources where people have mentioned this problem. There's an issue on Github with no answer. This page has a solution which works in my development environment, because it involves editing /lib/active_support/time_with_zone.rb
, but I need a solution that will also work in my production environment on Heroku. Is there a way I can use my edited version of /lib/active_support/time_with_zone.rb
on Heroku? Or is there a better way to deal with the problem?
Here's what I'm using:
Rails 3.0.1
ruby 1.9.2p0 (2010-08-18 revision 29036)
Thanks for reading.
Upvotes: 3
Views: 4574
Reputation: 951
I know this question was 2 years ago, but I think I found the clearer explanation about why it behave that way, found on this question. Just for anyone who probably need more explanations like me.
Upvotes: 2
Reputation: 795
irb> Time.now.getlocal
=> Mon Nov 08 15:04:05 +0200 2010
but
irb>DateTime.now.getlocal
NoMethodError: undefined method `getlocal' for Mon, 08 Nov 2010 15:05:16 +0200:DateTime
from (irb):17
So, I assume, you need to convert your DateTime object to Time
Updated
You can use Ruby mixin technique, something like
irb > module DateTimePatch
irb ?> def get_local
irb ?> "works!"
irb ?> end
irb ?> end
=> nil
irb > DateTime.send(:include, DateTimePatch)
=> DateTime
irb2 > DateTime.now.get_local
=> "works!"
Upvotes: 3