From 7640f27b9e183c6e9a00249c352e3515d3f90c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 2 Mar 2021 00:10:03 +0100 Subject: Rename db directory to models --- models/post.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 models/post.rb (limited to 'models/post.rb') diff --git a/models/post.rb b/models/post.rb new file mode 100644 index 0000000..1d44051 --- /dev/null +++ b/models/post.rb @@ -0,0 +1,18 @@ +class Post < ActiveRecord::Base + has_many :comments + has_many :tags, through: :post_tag_links + + validates_presence_of :title + validates_presence_of :body +end + +class CreatePostTable < ActiveRecord::Migration[6.0] + def change + create_table :posts do |t| + t.string :title, null: false + t.string :body, null: false + t.boolean :locked, default: false + t.timestamps + end + end +end -- cgit v1.2.3