Rails 4 scope adding a null `id` column to result -
i have class this:
class filedownload < activerecord::base scope :status, -> { select('user_id') } end
i'm using scope in controller return json response. worked fine in rails 3.2.14. response looked this:
[{ "user_id": 1234 }]
after upgrading rails 4, response looks this:
[{ "user_id": 1234, "id": null }]
can explain why null id field being added?
try pluck
:
scope :status, -> { pluck(:guid, :status) }
Comments
Post a Comment