On 5 July 2013 18:06, zip py <[email protected]> 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/CAL%3D0gLugY7o6g3wRTHcOz-AAJykkyeQ530XU8n2s9vG0%3DvrMBw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to