Hi, As of Rails 4, the order is by default based on the id DESC. So Model.last produces the following sql:
*SELECT * FROM models ORDER BY models.id DESC LIMIT 1* That said, I've no idea why you only get a part of the records back. Were you able to validates all those numbers directly on the DB? Regards Geoffroy Op vrijdag 5 juli 2013 23:16:14 UTC+2 schreef Colin Law het volgende: > > On 5 July 2013 18:06, zip py <[email protected] <javascript:>> wrote: > > Hi > > > > I have a Rail 4 with Postrgesql 9.1 setup that is working fine, apart > > from I just ran into an issue. > > > > Lets say I have a model called MyModel that has 150 records. > > > > If in IRB I try: > > > >> test = MyModel.all > > > > Only 138 records are returned. > > How do you know? > > > > > If I now try: > > > >> lastRecord = test.last > > > > The record I get has an ID of 138 > > If you have not specified an order clause then the order you get the > records in is undefined, so the last record is not necessarily the > highest id. > > > > > And yet if I try: > > > >> test.count > > > > It returns the correct value - 50! > > I presume you mean 150 > > Colin > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56352800-fcf0-4ad1-80b1-a1bcb75290f2%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.

