blob: 8b88b4a45352b5bd2f72ba50af2de88dadf0198e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
class User < ActiveRecord::Base
has_many :posts
validates_presence_of :username
validates_presence_of :password_hash
end
class CreateUserTable < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :name
t.string :username, null: false, unique: true, index: true
t.string :password_hash, null: false
t.timestamps
end
end
end
|