Hello,

I've just tried to make many_to_one association with some additions in 
block, like in this example:

class Car < Sequel::Model(DB[:default][:cars])
many_to_one :company, class: 'Company', read_only: true, do |ds| 
ds.select_append(
Sequel[:cars][:manufacturers].as(:producer),
).left_join(
:manufacturers,
Sequel[:cars][:manufacturer_id] => Sequel[:manufacturers][:id]
)
end end I am able to load association with additional attribute via 
car.company_dataset.first, 
but surprisingly car.company returns nil. What worked for me is to add 
optional after_load where after association is loaded I set a value with 
separate method. 
However, to be honest, I don't like this approach with separate method 
definition to handle this case. I am wondering if there is any smarter 
solution for this? Thanks!
Robert 

-- 
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 sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/369ebfdc-13b7-4d1f-8680-5dfa0089c5dbn%40googlegroups.com.

Reply via email to