Skip to content

Instantly share code, notes, and snippets.

@thefactus
Created November 8, 2023 22:21
Show Gist options
  • Save thefactus/f426b9de1976b474ca8b04fee375b79c to your computer and use it in GitHub Desktop.
Save thefactus/f426b9de1976b474ca8b04fee375b79c to your computer and use it in GitHub Desktop.
class User < ApplicationRecord
has_many :user_todo_lists
has_many :todo_lists, through: :user_todo_lists
has_many :todos, through: :todo_lists
end
class UserTodoList < ApplicationRecord
belongs_to :user
belongs_to :todo_list
end
class TodoList < ApplicationRecord
has_many :user_todo_lists
has_many :users, through: :user_todo_lists
has_many :todos
end
class Todo < ApplicationRecord
belongs_to :todo_list
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment