Here is a reference project for working with two associated models (User, Note) a user has many notes, a note belongs to a user.
Here we are using the session to store a user_id and an app level middleware to redirect requests before_action
in ApplicationController
clone the repo, your'll have to run the commands below before you get started
bundle install && rails db:migrate