You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
First of all, I would like to express my love for meta_where. I switched it off for debugging this issue and realized how more elegant is the syntax and the power it adds to AR.
Enhanced order clauses break when merged from associations
classToyBrand < ActiveRecord::Basebelongs_to:manuhas_many:toysscope:meta_order,joins(:manu).order({:manu=>:name},:name)#works if called directly, not when mergedscope:join_order,joins(:manu).order('manus.name, toy_brands.name')#this does direct and mergedendToyBrand.meta_order#worksclassToy < ActiveRecord::Basebelongs_to:toy_brandscope:order_via_meta,joins(:toy_brand).merge(ToyBrand.meta_order)# failsscope:order_via_string,joins(:toy_brand).merge(ToyBrand.join_order)# worksendToy.order_via_meta#fails
Related issue (due to AR)
See rails/rails#3002
With MetWhere active, the Toy.join_merge works!
In my test application everything works for this case. However, in my real application which is much more complicated, when I use the following scope:
like this: Shipment.find(106).shipping_items.joins(:item_variant).ordering_test
I get: MetaWhere::JoinDependency::ConfigurationError: Association named 'item_variants' was not found; perhaps you misspelled it? .../meta_where-1.0.4/lib/meta_where/join_dependency.rb:26:in build_with_metawhere'When I call the same thing over the association like this, it works beautifully:Shipment.find(106).shipping_items.joins(:item_variant).merge(ItemVariant.scoped)`
I'm really puzzled by this. I tried every combination. I would like to encapsulate all sortings in the respective models so the controllers just call the scope containing the wanted sorting without seeing the implementation....
Thanks for the help,
gam
Rails 3.0.9 / meta_where 1.0.4 / Ruby 1.9.2
The text was updated successfully, but these errors were encountered:
I've just updated an app to Rails 3.1 and realized about that too. The point is that we were using meta_where before and switched to squeel and then the "Association not found" exception started to appear. It's funny because I never thought this "behavior" was expected to happen without meta_where and that indeed meta_where properly handles merging scopes with joins.
First of all, I would like to express my love for meta_where. I switched it off for debugging this issue and realized how more elegant is the syntax and the power it adds to AR.
Enhanced order clauses break when merged from associations
Related issue (due to AR)
See rails/rails#3002
With MetWhere active, the Toy.join_merge works!
In my test application everything works for this case. However, in my real application which is much more complicated, when I use the following scope:
like this:
Shipment.find(106).shipping_items.joins(:item_variant).ordering_test
I get:
MetaWhere::JoinDependency::ConfigurationError: Association named 'item_variants' was not found; perhaps you misspelled it?
.../meta_where-1.0.4/lib/meta_where/join_dependency.rb:26:in
build_with_metawhere'When I call the same thing over the association like this, it works beautifully:
Shipment.find(106).shipping_items.joins(:item_variant).merge(ItemVariant.scoped)`I'm really puzzled by this. I tried every combination. I would like to encapsulate all sortings in the respective models so the controllers just call the scope containing the wanted sorting without seeing the implementation....
Thanks for the help,
gam
Rails 3.0.9 / meta_where 1.0.4 / Ruby 1.9.2
The text was updated successfully, but these errors were encountered: