Skip to content

Commit

Permalink
Fix delete post or users
Browse files Browse the repository at this point in the history
  • Loading branch information
tungnt247 committed Mar 11, 2021
1 parent 5f74845 commit 664fd2c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def create
end

def update
binding.pry
respond_to do |format|
if @post.update_attributes post_params
format.js do
Expand Down
2 changes: 1 addition & 1 deletion app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Post < ApplicationRecord
belongs_to :user
has_many :comments
has_many :comments, dependent: :destroy

with_options presence: true do
validates :title, length: { maximum: 250 }, uniqueness: { case_sensitive: false }
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class User < ApplicationRecord
has_many :posts
has_many :comments
has_many :posts, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :friend_sent, foreign_key: :sender_id, class_name: 'Relationship'
has_many :friend_request, foreign_key: :receiver_id, class_name: 'Relationship'
has_many :friends, -> { merge(Relationship.friends) }, through: :friend_sent, source: :receiver
Expand Down

0 comments on commit 664fd2c

Please sign in to comment.