In the first half of your question you describe exactly the solution you need. You've done everything right.
Imagine you have two users A, and B, and three records, X, Y and Z. User A has record Y, user B has record Z ... but both have record X.
You create your users:
a = User.create # id: 1
b = User.create # id: 2
and your records:
x = Record.create # id: 1
y = Record.create # id: 2
z = Record.create # id: 3
Then you set up your associations:
a.records << y
a.records << x
b.records << x
b.records << z
The product of this is 4 rows in your collections
table:
id | user_id | record_id
------------------------
1 | 1 | 2 # user A, record Y
2 | 1 | 1 # user A, record X
3 | 2 | 1 # user B, record X
4 | 2 | 3 # user B, record Z
This is how the join table works. It connects each user to all of its records, and each record to all of its users.
This allows you to do things like User.first.records
or Record.first.users
You're on the right track ... keep going and it'll start to click. Maybe rename your join table and model from collections
to RecordOwnerships
or something so that it makes more sense?