#395 ✓resolved
Tom Locke

Remove default_order (once we're on Rails 2.3)

Reported by Tom Locke | March 12th, 2009 @ 05:45 PM | in Hobo 1.0 - Final

Rails 2.3 has default_scope

Comments and changes to this ticket

  • Tom Locke

    Tom Locke March 12th, 2009 @ 05:45 PM

    • State changed from “new” to “open”
  • Tom Locke

    Tom Locke November 7th, 2009 @ 11:08 AM

    • Tag set to clean-up

    Folks, do you agree that we should get rid of this now that there's default_scope? Would be a big breaking change of course. Easy to fix but would affect a lot of apps.

  • Matt Jones

    Matt Jones November 8th, 2009 @ 07:32 PM

    I think it would be better to just implement set_default_order in terms of default_scope and keep the :default parameter scrubbing in find. I could also see a use case where, for instance, you have something like this:

      @model.other_models_with_a_weird_order.some_scope.find(:all, :order => :default)
    

    to unwind the order imposed by the other_model_with_a_weird_order association back to the default order for OtherModel. I think that works now, and it seems pointless to delete it.

  • Matt Jones

    Matt Jones November 8th, 2009 @ 07:34 PM

    I've also got #493 to look at on this issue.

  • Matt Jones

    Matt Jones November 22nd, 2009 @ 10:49 PM

    • Assigned user set to “Matt Jones”
  • Matt Jones

    Matt Jones November 30th, 2009 @ 10:00 PM

    Seeing tickets like this one:

    https://rails.lighthouseapp.com/projects/8994/tickets/2931-find-wit...

    makes me wonder if we should bother with default_scope at all. For clarification, here's where I'm seeing that the order defined by set_default_order should be used:

    • calls to find without an order. Note that the find shortcuts (:first, :last) don't do this currently and probably should, so that Foo.all.first == Foo.first.

    • loading / preloading associated records. So if Bar has_many :foos and Foo defines default_order on 'name', @bar.foos etc. should return records in order.

    • (nice to have) somehow whack this setting into the controller system, so that (for instance) a table-plus of the above Foo models would have the sort arrow preset for 'name'. This may be harder than it sounds.

  • Matt Jones

    Matt Jones November 30th, 2009 @ 11:24 PM

    • State changed from “open” to “resolved”

    This behavior is more consistent now, but not entirely consistent. ActiveRecord itself is pretty inconsistent - calling .find(:all, :order => xyz) on a scope that defines :order will merge the orders, but nesting two scopes with :order won't.

    Will revisit once AR makes a decision...

  • Matt Jones

    Matt Jones December 5th, 2009 @ 06:06 PM

    Another brick in the wall for default_scope:

    https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...

    Apparently still not interacting well with other scopes that define order...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Tags

Referenced by

Pages