Actually, it's even easier to specify the default order for a model:

    class User < ActiveRecord::Base
      set_default_order "name, created_at DESC"
    end

always learning new things...


On Thu, Mar 12, 2009 at 1:59 PM, Scott Bronson <[email protected]> wrote:
> If you specify :order => :default to a finder, Hobo will guess a
> default ordering to use.  Hobo also ensures that paginating find
> always specifies :order => :default.  This is very cool.
>
> So, how does Hobo figure out what the default order should be?  If
> your model specifies a default_order method (returning either the name
> of a column or a string suitable for find's :order parameter), then
> Hobo uses that.
>
> But here's the catch...  If your model doesn't specify default_order,
> then Hobo doesn't specify any ordering at all!  This tends to work OK
> on MySQL and sqlite, not so well on Postgres, and falls apart on SQL
> Server.
>
> Shouldn't Hobo ensure that some sort of ordering is specified?
> will_paginate's docs suggest that this is pretty important.
>  http://github.com/mislav/will_paginate/blob/8888651be8d6656bdf2378731d91a8badbaa2556/lib/will_paginate/finder.rb
>  (search for "The importance of the :order parameter)
>
> And, if so, then how should Hobo figure out what the default order
> would be?  created_at/created_on if it exists, otherwise primary key?
>
> Is this worth fixing?  I'm happy to write the patch if you guys think
> this is a good idea.
>
>    - Scott
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to