aboutsummaryrefslogtreecommitdiff
path: root/interfaces/ruby/models/post.rb
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces/ruby/models/post.rb')
-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 e952aed..3a29a1c 100644
--- a/interfaces/ruby/models/post.rb
+++ b/interfaces/ruby/models/post.rb
@@ -1,4 +1,5 @@
class Post < ActiveRecord::Base
+ belongs_to :user
has_many :comments
has_many :tags, through: :post_tag_links
@@ -10,6 +11,7 @@ end
class CreatePostTable < ActiveRecord::Migration[6.0]
def change
create_table :posts do |t|
+ t.references :user, foreign_key: true, null: false
t.string :slug, null: false, unique: true, index: true
t.string :title, null: false
t.string :body, null: false