Answer the question
In order to leave comments, you need to log in
How to understand why destroy does not work?
Even I can’t understand the guys, everything seems to be right, but they don’t want to delete it.
In Post controller
def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to taskpanel_posts_path, notice: 'Новость успешно удалена.' }
format.json { head :no_content }
end
end
<%= link_to 'Удалить', taskpanel_posts_path(@post), method: :delete, data: { confirm: 'Точно удалить?' } %>
Answer the question
In order to leave comments, you need to log in
Hold on. Your route is not correct. type #rake routes in the console and see the paths how to do it right
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to taskpanel_posts_path, notice: 'Новость успешно удалена.' }
format.json { head :no_content }
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question