Ruby on rails 3.2 销毁链接正在寻找显示
我的Rails应用程序有问题;特别是我的“销毁”链接将我带到显示页面。Destroy几个小时前还在工作(我试过了),但从那时起显然把事情搞砸了。我是Rails的相对初学者,我查阅了文档和本站点,试图找出如何自己解决这个问题,但没有成功。其他人也有类似的问题,我已经应用了对他们有效的修复,但也没有解决问题。希望有比我更先进的人能发现这个问题!我使用的是Rails v3.2.8 在index.html.erb中,我有:Ruby on rails 3.2 销毁链接正在寻找显示,ruby-on-rails-3.2,Ruby On Rails 3.2,我的Rails应用程序有问题;特别是我的“销毁”链接将我带到显示页面。Destroy几个小时前还在工作(我试过了),但从那时起显然把事情搞砸了。我是Rails的相对初学者,我查阅了文档和本站点,试图找出如何自己解决这个问题,但没有成功。其他人也有类似的问题,我已经应用了对他们有效的修复,但也没有解决问题。希望有比我更先进的人能发现这个问题!我使用的是Rails v3.2.8 在index.html.erb中,我有: def destroy @school = School.find(param
def destroy
@school = School.find(params[:id])
@school.destroy
respond_to do |format|
format.html { redirect_to schools_url }
format.json { head :no_content }
end
end
在schools_controller.rb中,我有:
def destroy
@school = School.find(params[:id])
@school.destroy
respond_to do |format|
format.html { redirect_to schools_url }
format.json { head :no_content }
end
end
这就是我在Rails服务器中看到的:
Started GET "/schools/7" for 127.0.0.1 at 2016-11-27 16:02:55 +0000
Processing by SchoolsController#show as HTML
Parameters: {"id"=>"7"}
School Load (0.0ms) SELECT "schools".* FROM "schools" WHERE "schools"."id" = ? LIMIT
1 [["id", "7"]]
Rendered schools/show.html.erb within layouts/application (1.0ms)
Completed 200 OK in 19ms (Views: 17.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2016-11-27 16:02:5
6 +0000
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2016-11-27 16:02:56
+0000
Served asset /application.js - 304 Not Modified (0ms)
My application.html.erb具有:
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
有人有什么想法吗?
谢谢,Catherine,在index.html.erb中,我将link改为button,它就工作了。在index.html.erb中,我将link改为button,它就工作了。请交叉检查你给出的链接,应该是这样的:
<%= link_to "REMOVE", remove_path , method: :delete %>
请交叉检查您的给定链接,它应该是这样的:
<%= link_to "REMOVE", remove_path , method: :delete %>
在包含删除链接的页面上是否存在JavaScript错误?如果是这样,修复它们-它们将停止使请求成为删除请求的JavaScript的工作。不,我没有看到任何错误。在包含删除链接的页面上有任何JavaScript错误吗?如果是这样,请修复它们-它们将停止将请求作为删除请求的JavaScript。不,我没有看到任何错误。