Ruby on Rails Model Association
Created by admin@example.com on March 28, 2025
1 | class User < ApplicationRecord
|
2 | has_many :posts, dependent: :destroy
|
3 | has_many :comments, dependent: :destroy
|
4 |
|
5 | validates :email, presence: true, uniqueness: true
|
6 | validates :username, presence: true, length: { minimum: 3, maximum: 25 }
|
7 | end
|