I'm following the rails tutorial (http://tutorials.jumpstartlab.com/projects/blogger.html#blogger-2), making a simple blog. In one of the exercises, it asks for me to implement the destroy method for my Articles_Controller (articles is the model for the blog post structure).
I've implemented the delete function, but afterwards, when trying to redirect_to article_path(@article), it can't find the record (of course it was deleted). I'm wondering how to redirect_to the index page?
After deleting an article, I get the rails error page and:
error: ActiveRecord::RecordNotFound in ArticlesController#show
my app/controllers/articles_controller.rb:
def destroy
@article = Article.find(params[:id])
flash.notice = "Article '#{@article.title}' destroyed."
redirect_to article_path(@article)
@article.destroy
end
The method as defined in ArticleController#show
def show
@article = Article.find(params[:id])
end