Skip to content

Commit 981d679

Browse files
author
TruongNM
committed
Fix foreign key for post
1 parent 637551e commit 981d679

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424

2525
# Ignore application configuration
2626
/config/application.yml
27+
public/*

app/models/post.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Post < ApplicationRecord
22
belongs_to :user
33
has_many :photos, dependent: :destroy
4-
has_many :likes, -> {order(:created_at => :desc)}
5-
has_many :comments, -> {order(:created_at => :desc)}
6-
has_many :bookmarks
4+
has_many :likes, -> {order(:created_at => :desc)}, dependent: :destroy
5+
has_many :comments, -> {order(:created_at => :desc)}, dependent: :destroy
6+
has_many :bookmarks, dependent: :destroy
77

88
def is_belongs_to? user
99
Post.find_by(user_id: user.id, id: id)

0 commit comments

Comments
 (0)