aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-03-02 21:35:34 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-03-02 21:35:34 +0100
commit0882804d708fe5a1732c6b9faa7d9a2f369f5257 (patch)
treeee071f5f7976ad2276e934d605a6473f31f1c3b1
parent1c956e662bb2072fa6e769ec5599dfab6db2c829 (diff)
downloadcomb-0882804d708fe5a1732c6b9faa7d9a2f369f5257.tar.gz
Add slug field
-rw-r--r--interfaces/ruby/models/post.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/interfaces/ruby/models/post.rb b/interfaces/ruby/models/post.rb
index 1d44051..e952aed 100644
--- a/interfaces/ruby/models/post.rb
+++ b/interfaces/ruby/models/post.rb
@@ -2,6 +2,7 @@ class Post < ActiveRecord::Base
has_many :comments
has_many :tags, through: :post_tag_links
+ validates_presence_of :slug
validates_presence_of :title
validates_presence_of :body
end
@@ -9,6 +10,7 @@ end
class CreatePostTable < ActiveRecord::Migration[6.0]
def change
create_table :posts do |t|
+ t.string :slug, null: false, unique: true, index: true
t.string :title, null: false
t.string :body, null: false
t.boolean :locked, default: false