diff options
author | John Ankarström <john@ankarstrom.se> | 2021-03-03 14:32:43 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-03-03 14:34:55 +0100 |
commit | d40c681d2f9d56e01cd5f1ff3e586b79ea4397f9 (patch) | |
tree | 5050c91c05807507cae5cc144037fb051d41b1f0 /interfaces/ruby/models/user.rb | |
parent | d072b503f5ccc5d08f279aac463d37837cbbb576 (diff) | |
download | comb-d40c681d2f9d56e01cd5f1ff3e586b79ea4397f9.tar.gz |
Add 'user' model
Diffstat (limited to 'interfaces/ruby/models/user.rb')
-rw-r--r-- | interfaces/ruby/models/user.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/interfaces/ruby/models/user.rb b/interfaces/ruby/models/user.rb new file mode 100644 index 0000000..8b88b4a --- /dev/null +++ b/interfaces/ruby/models/user.rb @@ -0,0 +1,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 |