【问题标题】:route index for a resource资源的路由索引
【发布时间】:2011-10-02 05:46:24
【问题描述】:

如果我手动写出资源 :topics 的等效索引路径是什么?
当我使用 routes.rb 文件中的资源行运行 rake 路由时,它会显示。

    GET    /topics(.:format)         {:action=>"index", :controller=>"topics"}

我尝试了一些没有成功的事情,例如:

    get 'topics/index' #=> 'topics#index'

【问题讨论】:

    标签: ruby-on-rails routes


    【解决方案1】:

    正如路线所说:

    get "/topics" => "topics#index", :as => :topics
    

    您现在可以使用topics_path 或topics_url

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-14
      • 2011-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-31
      • 2015-10-15
      • 1970-01-01
      相关资源
      最近更新 更多