未定义的方法“_index_path”form_for问题

我正在尝试使用RoR中的form_for帮助程序生成表单,但我遇到的似乎是路由错误。 以下是相关文件:

车型/ equipment.rb

class Equipment  true, :uniqueness => { :case_sensitive => true } end 

控制器/ equipments_controllers.rb

 class EquipmentsController  params[:page]) end def new @equipment = Equipment.new end end 

视图/设备/ new.html.rb

 

Add an equipment

f.object %>


的routes.rb

 EquipmentTracking::Application.routes.draw do root :to => "equipments#index" resources :equipments end 

我没有看到任何错误,但他们输出以下内容:

 NoMethodError in Equipments#new Showing /opt/ror/equipment_tracking/app/views/equipments/new.html.erb where line #2 raised: undefined method `equipment_index_path' for #<#:0xb6724640> 

如果我把它改成了

  

它似乎工作正常。 我也确定静态变量@equipment已经过了

  

回报

 # 

我在这里不知所措。 当我关注railstutorial.org书时,我就完成了我所做的工作,并完成了本书。

我认为你的问题在于你使用“设备”这个词。 如果你打开Rails控制台运行'equipment'.pluralize你会看到复数的“设备”是“设备”。

所以我会搜索你的项目并用“设备”替换任何“设备”的实例,我敢打赌它会修复它。