https://avo.cool logo
good morning friends, a short question
# general
m
good morning friends, a short question regarding attaching records in a
has_many ... through:
dialog: How can I avoid duplicates showing up in the select box? I have users I want to attach to segments, but of course it doesn't make sense to attach the same user to a segment twice I handle this on the database level using a unique index, but of course it'd be nice if those already connected users wouldn't show up in the select box at all...
l
Hi
attach_scope
😄
m
exactly
it's like, always when I ask a question I immediately find the answer
l
Does that mean that we have good docs? =))
We already thought of making that exclusion default, but maybe there are use cases where you want to attach same record more than once? (can't think of any use case like that right now)
m
to be honest, I was surprised to find duplicates in that select box
however, it'd be a breaking change. it would probably make sense on HABTM associations though, because the join table there already just consists of the two foreign keys (and often already has a unique index)
with has_many ... through ... there are potentially more use cases
l
Since is not that straightforward we let that configuration to be made according each project needs
When the assoicated record tables grows I think is more common to use
searchable: true
m
yeah, I just added this, but will this also conform to
attach_scope
?
seems like it does 👍
l
Yes