Thanks Rob, I actually have both but we can forget that model for the 
moment. The join table has an additional column "quantity". My objective is 
learning the correct sequel syntax to add a specified *quantity* of a given 
capability (c) into a plan (p) while using the sequel add_*association* 
method. (See my two pseudo code examples of syntax that does not work.) 
What syntax does?

On Sunday, September 5, 2021 at 12:23:14 PM UTC-7 [email protected] wrote:

> To me, that seems like you'd want a separate model, not a join table. - Rob
>
> On Saturday, September 4, 2021 at 5:41:11 PM UTC-7 John Knapp wrote:
>
>> I have a standard many_to_ many with a model for the join table. The join 
>> table has an extra attribute, "quantity".
>>
>> class Plan < Sequel::Model
>>     many_to_many :capabilities
>> end
>>
>> # join table with extra column "quantity"
>> class CapabilitiesPlans < Sequel::Model
>> end
>>
>> class Capability < Sequel::Model
>>     many_to_many :plans
>> end
>>
>> I can create the join record directly but that doesn't feel like the 
>> sequel way.
>>     CapabilitiesPlans.create(capability_id: c.id, plan_id: p.id, 
>> quantity:5)
>>
>> But how can I modify this syntax to add quantity?
>>     p.add_capability(c)
>> How to add the extra attribute using the add_*association* method?
>>
>> These two don't work:
>>     p.add_capability(c).quantity(5)
>>     p.add_capability(c, quantity: 5)
>>
>> I feel I must be missing something obvious but I've studied the docs and 
>> posts on here and have struck out! 
>>
>> I'd be happy to author documentation for this once I learn.
>>
>> --JK
>>
>

-- 
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/a4d80463-a41f-48d4-8681-425620eb4a02n%40googlegroups.com.

Reply via email to