aboutsummaryrefslogtreecommitdiff
path: root/interfaces/ruby/models/user.rb
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-03-03 14:32:43 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-03-03 14:34:55 +0100
commitd40c681d2f9d56e01cd5f1ff3e586b79ea4397f9 (patch)
tree5050c91c05807507cae5cc144037fb051d41b1f0 /interfaces/ruby/models/user.rb
parentd072b503f5ccc5d08f279aac463d37837cbbb576 (diff)
downloadcomb-d40c681d2f9d56e01cd5f1ff3e586b79ea4397f9.tar.gz
Add 'user' model
Diffstat (limited to 'interfaces/ruby/models/user.rb')
-rw-r--r--interfaces/ruby/models/user.rb17
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