Howdy! Huge fan of the forum, and all the work you do Jeremy.
I'm using the timestamps plugin, and I discovered that created_at isn't set
for join tables.
I've got two models (Group and User) connected via many_to_many, with a
typical join table groups_users.
It turns out my app hasn't been tracking when the associations were
created, even with the timestamps plugin applied to the join table's model.
In order to get the timestamp plugin to run, I've found I need to manually
insert the rows into the join table like so:
```
many_to_many :users, left_key: :group_id, right_key: :user_id, adder:
(lambda do |user|
GroupsUser.create(user_id: user.id, group_id: id)
end)
```
Here is a minimally reproducible example
<https://gist.github.com/lambwaves/521cca5193e2cafd17057e7b76d25ef3>, which
sets up the tables.
Is my solution the best way to track created_at for a join table in sequel?
Reviewing the forum, I've found three people also with this issue:
- Urbanski
<https://groups.google.com/g/sequel-talk/c/CSYxqEBOFyQ/m/5NWe4PglBwAJ> runs
into this issue, but doesn't post his solution
- Huang
<https://groups.google.com/g/sequel-talk/c/4Ybc88fgQFo/m/9DAFo4Z7AAAJ> is
told to use postgres triggers, which is a not starter for my team
- Manzer
<https://groups.google.com/g/sequel-talk/c/WAl_o5r8MWs/m/XubCTervm2kJ> uses
adder:, in a similar way for a different issue.
--
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/26bfcac6-857c-4185-ba2f-d1837ebf2a11n%40googlegroups.com.