Rails 3.0.3资源路由没有索引映射?

ibu*_*uck 24 routing ruby-on-rails

我正在尝试为我的楼宇控制器使用一个非常简单的资源路径.

resource :buildings
Run Code Online (Sandbox Code Playgroud)

这导致以下映射

buildings POST   /buildings(.:format) {:controller=>"buildings", :action=>"create"}
         new_buildings GET    /buildings/new(.:format)          {:controller=>"buildings", :action=>"new"}
        edit_buildings GET    /buildings/edit(.:format)         {:controller=>"buildings", :action=>"edit"}
                       GET    /buildings(.:format)              {:controller=>"buildings", :action=>"show"}
                       PUT    /buildings(.:format)              {:controller=>"buildings", :action=>"update"}
                       DELETE /buildings(.:format)              {:controller=>"buildings", :action=>"destroy"}
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么没有为默认/建筑物GET请求映射索引操作?我正在使用rails 3.0.3

Jer*_*ten 60

我想你想用resources而不是resource.你可以在这里阅读有关差异:http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resource

  • 嗯..就是这样。为此加油。 (2认同)
  • 你刚刚救了我的一天! (2认同)
  • 直到我碰到这20分钟才扑向我的头,谢谢! (2认同)