-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with use of DateTime in Recoverable concern #668
Comments
Thanks for your report, @emeryamiller! @sgrif Is this an AR bug? In that case we can move it to Rails. The following patch keeps CI green indeed, I'm not against such a PR into doorkeeper: diff --git a/lib/doorkeeper/models/concerns/revocable.rb b/lib/doorkeeper/models/concerns/revocable.rb
index 07b8ce8..96b70e1 100644
--- a/lib/doorkeeper/models/concerns/revocable.rb
+++ b/lib/doorkeeper/models/concerns/revocable.rb
@@ -1,12 +1,12 @@
module Doorkeeper
module Models
module Revocable
- def revoke(clock = DateTime)
+ def revoke(clock = Time)
update_attribute :revoked_at, clock.now
end
def revoked?
- !!(revoked_at && revoked_at <= DateTime.now)
+ !!(revoked_at && revoked_at <= Time.now)
end
end
end |
It's surprising to me nobody saw this before, though. |
Ya, I was surprised too. Had to double check it before reporting it to make sure I wasn't doing something silly. |
No, this doesn't look like a Rails bug. Generally we don't advise using |
Here is a gist explaining why it should be |
- Active record works better with Time, as opposed to DateTime objects, see issue doorkeeper-gem#668 for more details.
Closing in favor of good PR. Thanks! |
Fixes NoMethodError - undefined method 'getlocal' when calling the /oauth/token path. Active record works better with Time, as opposed to DateTime objects, see issue doorkeeper-gem#668 for more details. Also see https://gist.github.com/pixeltrix/e2298822dd89d854444b for more about when to use DateTime.
I'm getting a NoMethodError - undefined method `getlocal' when calling the /oauth/token path.
I'm using Ruby 2.1.5 and Rails 4.2 with Doorkeeper 2.2.1.
It looks like the issue stems from ActiveRecord calling
getlocal
on the object it's passed when updating the database. The issue is that the Recoverable concern passes a DateTime object, which doesn't have agetlocal
method. OnlyTime
has that.As an expedient fix for my code, I've updated the line:
to
This fixes the issue, but this looks more like an ActiveRecord bug, since I don't see why it wouldn't be able to handle DateTime objects.
Here is part of the stacktrace:
And the relevant code from active record:
The text was updated successfully, but these errors were encountered: