[LRUG] Strange AR scope behaviour
Ed James (Alt)
ed.james.spam at gmail.com
Wed Sep 4 05:50:40 PDT 2013
Hi all
I have a class like this (simplified of course):
class FileDownload < ActiveRecord::Base
scope :status, -> { select('guid, status') }
end
I'm using this scope in a controller to return a json response. This worked just fine in Rails 3.2.14. The response looked like this:
[{ "user_id": 1234 }]
After upgrading to Rails 4, suddenly the response looks like this:
[{ "user_id": 1234, "id": null }]
I've also tried this on the console, and it's the same.
Rails 3.2:
Rails 4:
Can anyone explain why the null id field is being added?
Thanks.
--
Ed James
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130904/ca2ef24a/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 35253 bytes
Desc: not available
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130904/ca2ef24a/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 35444 bytes
Desc: not available
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130904/ca2ef24a/attachment-0009.png>
More information about the Chat
mailing list