Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

count before where fails

#4811

The active record querying rails guide gives this example of querying:
Client.count.where("clients.first_name = 'Ryan' AND orders.status = 'received'").includes("orders")

However when I do that I get the error:
undefined method where' for Fixnum

Which means to me that it is doing the count before taking into account the where. I don't know if this is a bug or not. For now I'll just move my count method to after the where.

Reported by Darren Hinderer · June 9th, 2010 @ 05:29 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh

    I think the doc needs to be updated to reflect that "count" should be applied at the very end.

    Could you please point out where in the doc you got what you referred to. Thanks.

    June 9th, 2010 @ 08:02 PM

  2. Darren Hinderer
  3. Rohit Arondekar
    Rohit Arondekar

    Fixed in this commit http://github.com/lifo/docrails/commit/b7a305f0cb7bf0cebc6f053b9faa...

    Thank you for reporting the issue. And feel free to report any other problems you find in the guides. :)

    June 13th, 2010 @ 11:09 AM

  4. Ryan Bigg
    Ryan Bigg
    • State changed from new to resolved

    June 14th, 2010 @ 10:06 AM