Ruby on Rails “count” method

Check this out:

Ruby on Rails “count” method documentation

Can anyone, anywhere, tell me why “: order” would be needed if I am counting something? (Please note, space inserted so that wordpress doesn’t convert it into a smiley).

There are so many other holes and discrepancies in the Rails docs that I won’t try and list them, but this one takes the cake so far.

Advertisements

2 thoughts on “Ruby on Rails “count” method

  1. Maybe if you are grouping at the same time, for example:
    ID | User | Colour
    – – – – – – – – – –
    1 | Fred | Blue
    2 | Tom | Red
    3 | Jane | Blue
    4 | Joe | Green

    My sql is rusty, but if I remember correctly
    orderby ID, Group by Colour, count of rows = 4,
    whereas
    Orderby Colour, Group by Colour, count of rows = 3.
    the key word ‘distinct’ also comes to mind (I remember spending hours searching a problem to discover that was the word that solved everything)

    I could be wrong on all that though, so do double check that

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s