【问题标题】:Rails 3.0.3 resource route no index mapped?Rails 3.0.3 资源路由没有映射索引?
【发布时间】:2011-06-20 07:46:43
【问题描述】:

我正在尝试为我的建筑物控制器使用一个非常简单的资源路由。

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

有人知道为什么没有为默认的 /buildings GET 请求映射索引操作吗?我正在使用 rails 3.0.3

【问题讨论】:

    标签: ruby-on-rails routing


    【解决方案1】:

    我认为您想使用resources 而不是resource。您可以在此处了解不同之处:http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resource

    【讨论】:

    • 啊..是的。为此干杯。
    • 你拯救了我的一天!
    • 20 分钟的打击我的头,直到我遇到这个,谢谢!
    • 8 年后,你拯救了我的一天。无论你今天在哪里,我祝你一切顺利,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    • 2016-11-12
    相关资源
    最近更新 更多