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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -