【发布时间】:2020-12-26 02:58:36
【问题描述】:
我是 Rails 新手,似乎无法弄清楚这一点
每次我点击链接时,它都不会删除文章,只是将我带到显示视图。不知道为什么会这样。这是我的链接代码:
<%= link_to 'delete', article_path(article.id), method: :delete, data: { confirm: "Are you sure?" } %>
即使我指定了方法(我认为),我的 rails 服务器仍显示 GET 请求:
Started GET "/articles/1" for ::1 at 2020-09-07 10:05:13 -0700
Processing by ArticlesController#show as HTML
Parameters: {"id"=>"1"}
Article Load (0.7ms) SELECT "articles".* FROM "articles" WHERE "articles"."id" = ? LIMIT ?
[["id", 1], ["LIMIT", 1]]
↳ app/controllers/articles_controller.rb:46:in `set_article'
Rendering articles/show.html.erb within layouts/application
Rendered articles/show.html.erb within layouts/application (Duration: 4.0ms | Allocations: 321)
[Webpacker] Everything's up-to-date. Nothing to do
Rendered layouts/_flashMessages.erb (Duration: 0.2ms | Allocations: 18)
Rendered layouts/_navBar.html.erb (Duration: 0.1ms | Allocations: 5)
Completed 200 OK in 123ms (Views: 96.9ms | ActiveRecord: 0.7ms | Allocations: 5344)
我不知道为什么。任何帮助表示赞赏。谢谢!
【问题讨论】:
标签: ruby-on-rails ruby link-to