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

时间:2011-02-02 22:33:18

标签: ruby-on-rails routing

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

resource :buildings

这导致以下映射

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"}

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

1 个答案:

答案 0 :(得分:58)

我认为您要使用resources代替resource。您可以在这里阅读有关差异的内容:http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resource