#109 ✓moved_to_github
Mark Dodwell

#search ignores :order argument on associations which have an order defined

Reported by Mark Dodwell | July 28th, 2009 @ 07:01 PM

Consider a class Foo, with associated Bars:

class Foo < ActiveRecord::Base  
  has_many :bars, :order => :name

If you do:

Foo.bars.search(:order => "ascend_by_size").all

The results are still sorted by :name -- i.e. the "ascend_by_size" :order argument to the #search method is ignored.

The SQL query looks like:

SELECT * FROM bars WHERE bars.foo_id = 1 ORDER BY bars.name;


Is this a bug?

Comments and changes to this ticket

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 ยป

Provides common named scopes and object based searching.

People watching this ticket