From 0882804d708fe5a1732c6b9faa7d9a2f369f5257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 2 Mar 2021 21:35:34 +0100 Subject: Add slug field --- interfaces/ruby/models/post.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'interfaces/ruby/models') 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 -- cgit v1.2.3