【问题标题】:Rails Routes deprecation warningRails Routes 弃用警告
【发布时间】:2015-06-03 08:58:54
【问题描述】:

我有一个 Rails 4.2.1 应用程序并在我的 routes.rb 中收到弃用警告

DEPRECATION WARNING: Defining a route where `to` is a controller without an action is deprecated. Please change `to: :super_admin` to `controller: :super_admin`. (called from block in <top (required)>

路线看起来像这样:

 get "/super_admin(/:action(/:id))", :to => "super_admin", :constraints => {:subdomain => "admin"}
 get "/", :to => redirect("/super_admin"), :constraints => {:subdomain => "admin"}
 get "/super_admin(/:action(/:id))", :to => "super_admin", :constraints => {:subdomain => "admin.staging"}
 get "/", :to => redirect("/super_admin"), :constraints => {:subdomain => "admin.staging"}
 get "/super_admin(/:action(/:id))", :to => redirect("/")

我需要改变什么?

【问题讨论】:

  • 为什么会被赞成?

标签: ruby-on-rails ruby ruby-on-rails-4


【解决方案1】:

使用controller: :super_admin 代替to: :super_admin。弃用警告消息中也提到了这一点。

【讨论】:

  • 真正正确的是::controller =&gt; :super_admin 但感谢您的提示!
  • 很高兴为您提供帮助:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-23
  • 2017-03-06
  • 2011-10-03
相关资源
最近更新 更多