app/controllers/posts_controller.rb
#user can delete their own posts

user can delete their own posts
user can delete their own posts
def destroy
        @post = Post.find(params[:id])
        if current_user.id == @post.user_id
            @post.destroy
            redirect_to '/posts'
            flash[:error] = "Post was deleted."
        else
            flash[:error] = "You cannot delete others' posts!"
        end
    end
def destroy @post = Post . find ( params [ :id ] ) if current_user . id == @post . user_id @post . destroy redirect_to '/posts' flash [ :error ] = "Post was deleted." else flash [ :error ] = "You cannot delete others' posts!" end end
user can delete their own posts
user can delete their own posts