Topic: multiple users id

I am building a messages model.
In my model i have a user_id (for whom the message is for)
but some one else could pick up the message so i added a pickup_user_id

now when i do


i get all the user info

but how can i map pickup_user_id  to the same way. so i can go


and get the user info?


Re: multiple users id

May be by using polymorphic associations: … ociations.
In this case, your message would be 'pickable' or smth like that, i.e. it could be îcked up by users.
Another way is to use an intermediate table/model, it depends if you want to have a relation like many-to-many between users and messages.

Re: multiple users id

I will read that guide.

What i did was something that i did not like as that was in the view i had

user = User.find(message.last.pickup_user)

but i am sure what i am going to read now is better