Has_many :through with :order column on the join model

I have a model like so

class Product < ActiveRecord::Base
has_many :image_links, :order => :position
has_many :product_images,
:order => ‘image_links.position’,
:through => :image_links
end

The problem is that :order clause just gets ignored. How do you server
records in a specific order when the order column is on the join model?

@product.product_images produces this SQL:

SELECT product_images.id, product_images.created_at FROM product_images
INNER JOIN image_links ON product_images.id =
image_links.product_image_id WHERE (image_links.product_id = 1) ORDER BY
image_links.position

Whats the problem here?

Alex W. wrote:

I have a model like so

class Product < ActiveRecord::Base
has_many :image_links, :order => :position
has_many :product_images,
:order => ‘image_links.position’,
:through => :image_links
end

The problem is that :order clause just gets ignored. How do you server
records in a specific order when the order column is on the join model?

@product.product_images produces this SQL:

SELECT product_images.id, product_images.created_at FROM product_images
INNER JOIN image_links ON product_images.id =
image_links.product_image_id WHERE (image_links.product_id = 1) ORDER BY
image_links.position

Whats the problem here?

Ok, it was apparently working jsut fine and I had a bad test.

Color me embarrased.

I believe that this is covered by ticket #3438

http://dev.rubyonrails.org/ticket/3438

Stephen G.