My spec changed so I won't be needing this, but I'll be keeping this in my 
back pocket to try I need to order off an association.

On Sunday, November 19, 2023 at 12:21:37 AM UTC-8 Jeremy Evans wrote:

> On Sat, Nov 18, 2023 at 10:52 PM [email protected] <[email protected]> 
> wrote:
>
>> lets say you have:
>>
>> class User
>>   one_to_one :best_purchase, class: :Purchase
>> end
>> class Purchase
>>   many_to_one :product
>> end
>> class Product
>>   # has column :tier which is a number. 
>> end
>>
>> I want to do something like 
>>
>> class User
>>   one_to_one :best_purchase, 
>>     class: :Purchase, 
>>     order: Sequel.desc(Sequel[:product][:tier]), 
>>     add_join :product
>> end
>>
>> Is there a way to do this?
>>
>
> I haven't tried this, but you can try an association block:
>
>   one_to_one :best_purchase,
>     class: :Purchase, 
>     order: Sequel.desc(Sequel[:product][:tier]) do |ds|
>       ds.association_join(:product)
>     end
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a75c801d-d1eb-4ee0-8055-8c3ca7289650n%40googlegroups.com.

Reply via email to