Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update getting started guide using turbo #43974

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions guides/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ class ArticlesController < ApplicationController
@article = Article.find(params[:id])
@article.destroy

redirect_to root_path
redirect_to root_path, status: 303
end

private
Expand All @@ -1293,7 +1293,8 @@ on it. Then, it redirects the browser to the root path.

We have chosen to redirect to the root path because that is our main access
point for articles. But, in other circumstances, you might choose to redirect to
e.g. `articles_path`.
e.g. `articles_path`. Additionally we return an `303` status code, which lets the
browser know, the deletion worked.

Now let's add a link at the bottom of `app/views/articles/show.html.erb` so that
we can delete an article from its own page:
Expand Down Expand Up @@ -1973,8 +1974,7 @@ So first, let's add the delete link in the

<p>
<%= link_to 'Destroy Comment', [comment.article, comment],
method: :delete,
data: { confirm: "Are you sure?" } %>
data: { turbo_method: :delete, turbo_confirm: "Are you sure?" } %>
</p>
```

Expand All @@ -1995,7 +1995,7 @@ class CommentsController < ApplicationController
@article = Article.find(params[:article_id])
@comment = @article.comments.find(params[:id])
@comment.destroy
redirect_to article_path(@article)
redirect_to article_path(@article), status: 303
end

private
Expand Down