Had a case where calling in an associated class, but don't seem to be able to determine how Rails sucks the data out of MySql - so have had to sort it after the fact.
This little bit of code seems to do the trick
@jobs.sort! { |a,b| b.id <=> a.id }
This is descending - if you want ascending then swap over b.id and a.id.
Don't ask me what is actually going on - but it works
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment