Midburn / Dreams

A platform for planning and crowdfunding co-created events.
Do What The F*ck You Want To Public License
4 stars 8 forks source link

Dreams Managers and crew might change order or disappear over time #267

Closed enoodle closed 6 years ago

enoodle commented 6 years ago

The issue is revolving around a thing with rails that first and [0] don't necessarily return the same object on association. It hits us in [1] and [2], where due to creations and deletions or people from the system, @camp.people.first != @camp.people[0] and then the person on @camp.people[0] won't show and that person might change over time. I am not sure how rails decides this order, but it is probably has something to do with the ID numbers.

[1]https://github.com/Midburn/Dreams/blob/master/app/views/camps/_form.haml#L357 [2]https://github.com/Midburn/Dreams/blob/master/app/views/camps/_form.haml#L376

enoodle commented 6 years ago

Best description of this that I found on google: https://coderwall.com/p/b-kfba/when-limit-1-first-is-orders-of-magnitude-slower-than-limit-1-0-in-rails

first adds an ORDER BY id to the sql search, which for us on some case will cause the return value to be different from @camp.people[0] and this will hide this entry and display the .first one twice.