[openstreetmap/openstreetmap-website] Pass the user object, rather than the id, for sessions (#1456)

Tom Hughes notifications at github.com
Wed Feb 22 10:54:36 UTC 2017


There are multiple different contexts here which are getting confused...

In the controller tests thing like `get` take two hashes - the first is arguments and I am surprised any conversion happens there although it seems that is must be converting objects to IDs implicitly. I would prefer not to do that though an ID is what is expected there and what would be passed in a real URL based call.

The second is the session hash, and we store a user ID in our session hash under the `:user` key so again I am tempted to say we should be explicit about that (ie the opposite of this change) and not rely on rails to do some magic conversion.

In the actual rails code you can for example do `:user => user` which matches on the association or `:user_id => user.id` which matches on the actual attribute (field) and apparently you can also do `:user => user.id` and rails magically fixes it but again my preference would be not to rely on that.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/1456#issuecomment-281635961
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20170222/42f93eab/attachment.html>


More information about the rails-dev mailing list