我正在关注指南http://guides.rubyonrails.org/getting_started.html
Ruby 1.9.2p0
Rails 3.0.0
但当我尝试添加;
时,我被锁定在6.2 / 6.3我收到错误(我将Post示例切换为Specie);
Home#index中的ActionController :: RoutingError 没有路线匹配{:action =>“destroy”,:controller =>“species”}
终端历史:
捆绑安装
rake db:创建
rails生成控制器主目录
rm public / index.html
rails generate scaffold物种名称:string latin:string
rake db:migrate
路径localhost:3000 / species / works但不是localhost:3000 / species / new
耙路线:
species_index GET /species(.:format){:action =>“index”,:controller =>“species”} species_index POST /species(.:format) {:action =>“create”,:controller =>“species”} new_species GET /species/new(.:format){:action =>“new”,:controller =>“species”} edit_species GET /species/:id/edit(.:format) {:action =>“edit”,:controller =>“species”} 种类GET /species/:id(.:format){:action =>“show”,:controller =>“species”} 种类PUT /species/:id(.:format) {:action =>“update”,:controller =>“species”} 物种DELETE /species/:id(.:format){:action =>“destroy”,:controller =>“species”} home_index GET /home/index(.:format) {:controller =>“home”,:action =>“index”}
root /(.:format) {:controller =>“home”,:action =>“index”}
的routes.rb
资源:物种
得到“家/索引”
root:to => “home #index”
答案 0 :(得分:10)
您的问题是species
的复数是species
(它们是相同的)。
答案在rake routes
。请注意,您将要使用:
<%= link_to "All Species", species_index_path %>
有关详情,请参阅路线指南中的Section 4.8 - Overriding The Singular Form。