【发布时间】:2016-01-19 20:31:21
【问题描述】:
问题在于第 2 章第 2.2.1 节中讨论的脚手架生成的用户删除链接不执行删除操作。相反,它与 Show 链接的作用相同。
我已经搜索了这个问题并找到了一些报告(Why Delete link doesn't work in this Ruby on Rails project? 和 Rails 3 :method=> :delete doesn't work in Internet Explorer),但它们是 4 年和 5 年前的,并且建议的解决方案引用了比当前版本老得多的 rails 和 gem 版本。
此外,似乎对某些人有用的建议解决方案之一是修改 application.html.erb 以使用 true %> 代替 defaults', 'data-turbolinks-track' => true %> 但这会撤消我几天前发布的问题的修复 (Michael Hartl's Ruby on Rails Tutorial, toy_app user tour)。
我在 Windows 7 上使用 Firefox,我的 gem 文件在下面。我已验证浏览器中启用了 Javascript。对于当前版本的 rails 等,什么是适当的修复?
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'sass-rails', '~>5.0'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'sqlite3'
gem 'byebug', '3.4.0'
gem 'web-console', '~> 2.0'
gem 'spring', '1.1.3'
end
group :production do
# Gems for Heroku deployment
gem 'pg'
gem 'rails_12factor'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
【问题讨论】:
-
你能告诉我们你的索引视图吗?
-
另外,您在日志中看到了什么?它是否使用正确的 http 动词调用正确的控制器操作?有没有类似
Started DELETE "/users/2"...Processing by UsersController#destroy as HTML -
抱歉,我是 RoR 的新手。索引视图是什么文件?对于日志,我根本看不到任何对 DELETE 的引用。它以“Started GET ...”开头,并且 DEFAULTS javascript_include_tag 存在路由错误。
标签: ruby-on-rails ruby-on-rails-4