Exclude columns that would be Foriegn Keys
# Example: Table Page with column "title"
rails g model Page title:string
rails g model Category name:string
Example: Pages can belong to a category.
Page association
In your models/page.rb
file, add association
class Page < ApplicationRecord
belongs_to :category
end
Category association
In your models/category.rb
file, add association
class Category < ApplicationRecord
has_many :pages
end
Create migrations with associations
rails g migration AddCategoryRefToPages category:references
Scaffold controller and views for models
rails g scaffold_controller Page title category_id
rails g scaffold_controller Category name
rails db:migrate