Why do we need a through table explained with Rails?

Written by fer | Published 2020/10/20
Tech Story Tags: relationships | ruby-on-rails | database | optimization | infrastructure | rails | programming | coding

TLDR In a many to many relationship, it's just a table between the entities, but what is the purpose of this table to be between them? In Rails we can create two models and these 2 models can be connected just with a foreign key by Active Record Associations. The user_id is going to be our foreign key, remember that primary keys are unique between models, so in order to reference our User model, we can start saying "A User can have many events but an Event belongs to one single user"via the TL;DR App

no story

Published by HackerNoon on 2020/10/20