refinery / refinerycms-page-images

Adds an images tab to your pages so you can format a group of images really nicely on the frontend
104 stars 120 forks source link

Unknown column 'position' in 'order clause' #113

Open asgeo1 opened 10 years ago

asgeo1 commented 10 years ago

Strangely my site was working fine when I was using PostgreSQL. Recently I tried it out on MySQL, and now this extension throws an error:

Mysql2::Error: Unknown column 'position' in 'order clause': SELECT `refinery_images`.* FROM `refinery_images` WHERE `refinery_images`.`id` IN (1) ORDER BY position ASC

I fixed it by changing the association in lib/refinery/page_images/extension.rb:

from:

has_many :images, proc { order('position ASC') }, :through => :image_pages, :class_name => 'Refinery::Image'

to:

has_many :images, proc { includes(:image_pages).order('refinery_image_pages.position ASC') }, :through => :image_pages, :class_name => 'Refinery::Image'

I'm using Rails 4.1.4

Not sure if it's worth making this change to refinerycms-page-images, or whether it's an issue with the rails MySQL2 adapter ?

bricesanchez commented 6 years ago

Did you find a solution @asgeo1 ?