Board Game Collections — Sinatra Project

Active Record Associations

In order to get this app functioning in the way I envisioned, I needed to set up a many-to-many relationship between users and board games (i.e. a user has many board games, but a board game can also be owned by many different users). I achieved this by creating a join table called user_boardgames.

app/models/user_boardgame.rb
app/models/user.rb
app/models/boardgame.rb
app/controllers/boardgame_controller.rb
app/controllers/boardgame_controller.rb
app/views/users/edit.erb
app/controllers/user_controller.rb
app/views/users/show.erb
app/controllers/user_controller.rb

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store