On Tuesday, July 7, 2020 at 11:25:49 AM UTC-7, Aryk Grosz wrote:
>
> I'm having trouble with #with_extend.
>
> I can extend methods from another module but I cannot continue chaining 
> for example association join.
>
> class Garage < Sequel::Model
>
> one_to_many :cars
>
> end
>
>
> class Car < Sequel::Model
>
> one_to_many :seats
>
> module Foo
>   def steer_car
>     association_join(:seats)
>   end
> end
> dataset_extend Foo
>
> end
>
> garage.association_join(:cars).with_extend(Car::Foo).steer_car # -> this 
> will give an error because association_join still thinks we are in Garage 
> model and there is no :seats association in Garage.
>

Which makes sense, because you are in the Garage model, not the Car Model.  
Use Car.association_join(:garage).steer_car if you want to use dataset 
methods of Car.

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/c2bfeb6e-d2ec-4057-a415-4185d5a3fe4co%40googlegroups.com.

Reply via email to