We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 637551e commit 981d679Copy full SHA for 981d679
.gitignore
@@ -24,3 +24,4 @@
24
25
# Ignore application configuration
26
/config/application.yml
27
+public/*
app/models/post.rb
@@ -1,9 +1,9 @@
1
class Post < ApplicationRecord
2
belongs_to :user
3
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
+ has_many :likes, -> {order(:created_at => :desc)}, dependent: :destroy
+ has_many :comments, -> {order(:created_at => :desc)}, dependent: :destroy
+ has_many :bookmarks, dependent: :destroy
7
8
def is_belongs_to? user
9
Post.find_by(user_id: user.id, id: id)
0 commit comments