[LRUG] Clearance: problems with equivalence of #current_user
John Maxwell
John.Maxwell at boardintelligence.co.uk
Tue Apr 21 08:12:33 PDT 2015
If you’re using SimpleDelegator this will break though:
u1 = User.first
u2 = SimpleDelegator.new(u1)
u1 == u2 #=> false
Is something wrapping your user without you noticing?
John Maxwell
Lead Developer
Board Intelligence Ltd
Registered in England and Wales No. 4529306
Head Office: 5 St. James¹s Place | London SW1A 1NP | UK
+44 (0)207 192 8200 | www.boardintelligence.co.uk |
https://twitter.com/BoardIntel
EMAIL DISCLAIMER: The information contained in this email is private and
confidential and may be legally privileged. It is intended solely for the
addressee and any disclosure, copying or dissemination of it is
prohibited, will be a breach of the writer's copyright and may be unlawful
in other respects. It should be noted that Board Intelligence Ltd. never
enters into contracts via email nor email attachment and that no employee
or representative of Board Intelligence Ltd. has the authority to override
that policy. If you have received this transmission in error then you must
inform info at boardintelligence.co.uk.
On 21/04/2015 16:10, "Tom Stuart" <tom at codon.com> wrote:
>On 21 Apr 2015, at 15:56, Stephen Best <bestie at gmail.com> wrote:
>> To make Array#include? work as you expect for two different instances
>>of the same user record you would have to redefine equality (User#==) in
>>terms of the object values or maybe just the id.
>
>If `User` is a subclass of `ActiveRecord::Base`, the `User#==` method
>should already do this:
>https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_rec
>ord/core.rb#L377-L391
>
>Cheers,
>-Tom
>_______________________________________________
>Chat mailing list
>Chat at lists.lrug.org
>Archives: http://lists.lrug.org/pipermail/chat-lrug.org
>Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
>List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4496 bytes
Desc: not available
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20150421/002deb62/attachment-0004.bin>
More information about the Chat
mailing list