ruby-on-railspostgresqlids

Rails ids returning more records


I don't know if someone has had this issue:

When I do Question.count it returns 3112, but when I run Question.ids.count the result is 9685.

Is my database broken?


Solution

  • Well it seems when you include children in your query, also those ids are coming with the results. I had default_scope { includes(:choices) }, I removed it and everything works fine.