devise-activegraph icon indicating copy to clipboard operation
devise-activegraph copied to clipboard

DateTime nil not supported by neo4j

Open jelmerderonde opened this issue 9 years ago • 7 comments

I have never before submitted an issue on GitHub or anywhere else, so please let me know if I'm doing something wrong.

I am now working on integrating devise-neo4j with my app. After adding the recoverable property to my User model I ran into an issue. When submitting a new password, it returns the error that the year method is not supported by NilClass. It appears that devise tries to set the reset_password_at property to nil. Upon saving to the neo4j database this gives an error.

It seems to me that this is an issue for devise-neo4j, because it could be normal behaviour for both devise and neo4j, but I'm not sure.

Let me know what I can do to help fix this issue.

jelmerderonde avatar Feb 28 '15 16:02 jelmerderonde

Hey @jelmerderonde. It would be good to know some more details about the error. Perhaps you could paste a gist showing it? Or a bare minimum example project that makes the error happen because the tests for Devise with neo4j all seem to be passing fine.

If you just wanted a quick-ish fix, you could try extending Recoverable and overwriting the after_password_reset method (which is empty in Devise's Recoverable module), to set whatever you need in order for the error not to occur.

benjackson avatar Mar 02 '15 11:03 benjackson

Hi @benjackson,

Thanks for the quick reply. A gist showing the rails server output when the error occurs: https://gist.github.com/jelmerderonde/2930788bfed7b80f4b2b

A minimum project would frankly be just rails, neo4j and devise-neo4j, with a single User resource with the Recoverable module. When a user tries to reset their password, because devise tries to set the reset_sent_at to nil which is not accepted.

I did some more research and I think it might be because of this commit in neo4jrb: https://github.com/neo4jrb/neo4j/commit/f8689b5c7630e32cb0c21248939589923c5e596b#diff-3fa03f2e2089eba3ae28988a375ac16a

However I'm not sure of this. I will try to implement the fix you mentioned, but if you have any suggestion on what I can do to implement a more complete fix let me know.

jelmerderonde avatar Mar 02 '15 20:03 jelmerderonde

Sorry for coming into this a little late. I'm still a little unsure about how it's getting to the point that it can try to convert a nil value. Do we know where reset_sent_at is defined?

subvertallchris avatar Mar 02 '15 20:03 subvertallchris

@subvertallchris I think it is here: https://github.com/plataformatec/devise/blob/master/lib/devise/models/recoverable.rb

line 85

jelmerderonde avatar Mar 03 '15 07:03 jelmerderonde

@jelmerderonde I haven't tried a real example yet, but any idea why this integration test that gets run as part of all the devise tests wouldn't suffer from the same issue you're seeing?:

https://github.com/plataformatec/devise/blob/master/test/integration/recoverable_test.rb

benjackson avatar Mar 04 '15 18:03 benjackson

@benjackson is there a way I can run these tests in the context of my app? I will take a look at it.

jelmerderonde avatar Mar 07 '15 19:03 jelmerderonde

@jelmerderonde you could just recreate the integration test that covers the functionality that is breaking for you, but that might still be something attributable to your app rather than the gem.

If you're able to create an example in a public repo, with a failing integration test, I'd be happy to take a look and see if I can figure out why the Devise test doesn't capture the same problem.

benjackson avatar Mar 09 '15 13:03 benjackson