Hi Dr.!
when I use order with update_all, i get:
TypeError: can't convert CompositePrimaryKeys::CompositeKeys into String
from /Users/me/.rvm/gems/ruby-1.9.2-p180/gems/arel-3.0.2/lib/arel.rb:39:in `initialize'
from /Users/me/.rvm/gems/ruby-1.9.2-p180/gems/arel-3.0.2/lib/arel.rb:39:in `new'
from /Users/me/.rvm/gems/ruby-1.9.2-p180/gems/arel-3.0.2/lib/arel.rb:39:in `sql'
from /Users/me/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:308:in `join_to_update'
from /Users/me/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.2.11/lib/active_record/relation.rb:287:in `update_all'
...
The code looks like this:
shops = Shop.where("shops.source = ? AND shops.meta_source IS NULL AND shops.company_url IS NOT NULL AND shops.company_url <> ''",
source.id)
count = shops
.joins("INNER JOIN shops AS meta_shops ON shops.company_url = meta_shops.company_url"
.order("shops.source, shops.source_id, meta_shops.source, meta_shops.source_id") # Works without this
.update_all("shops.meta_source = meta_shops.source, shops.meta_source_id = meta_shops.source_id")
Best Jan