has-friendship/has_friendship

Separate table/model for friendship blocking records

Opened this issue · 8 comments

friendship table contains too much information, it would be nice if some of them are decoupled.

I think it'd be a good idea to make a separate table/model for records for friendship block/unblock, with blocker_id and blockee_id.

If we have a blocker_id we don't need a blockee_id. We could also just add a "blocked" and "bocked_by" status; according to whom blocked the relation.

You're right. We don't need both blocker_id and blockee_id. Plus, they sound funny. Maybe the new table blocked_friendships could have friendship_id foreign key and blocker_id, and blocker_type to make the polymorphic association complete.

I have been thinking about it and it seems more logical to me to keep the same convention you used for the friendship request. That way we keep the table cleaner. I think we should add some validations too

What convention do you mean? Do you mean that we keep the current structure?

Just like for a request we have "requested" and "pending", we can do the same for blocked records: for example we can have "blocked" and "blocked_by"

That's a reasonable approach. We could add statuses like was_blocked and did_block. I think this is not an urgent feature because current setup works just fine. This is something to consider in the future improvement. Let's sit on it and wait for more input from the others.

By the way your PR was very helpful. Would you like to be a collaborator for this gem?

Sure:) It would be fun to keep collaborating in this project