Jeremy can answer authoritatively but AFAIK it does not exist and is a bit of an oxymoron- "join tables" as Sequel defines them are just a compound key; adding an additional attribute ceases to make them a join table. I'm not going to explain why you should use a separate model for this since you didn't ask for it, but having been down this road I would definitely say use a separate model. - Rob
On Sunday, September 5, 2021 at 2:33:41 PM UTC-7 John Knapp wrote: > 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/773390d9-e0ce-4d54-836b-c026188b047dn%40googlegroups.com.
