弃用警告:不建议在路线中使用动态:controller区段,并将在Rails 5.1中将其删除 [英] DEPRECATION WARNING: Using a dynamic :controller segment in a route is deprecated and will be removed in Rails 5.1

查看:137
本文介绍了弃用警告:不建议在路线中使用动态:controller区段,并将在Rails 5.1中将其删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有警告的config / routes.rb

I have config/routes.rb with warning

DEPRECATION WARNING: Using a dynamic :controller segment in a route is deprecated and will be removed in Rails 5.1.

不知道如何重写以删除警告。
任何了解如何操作的文档。或新代码
Thx。

Don't know how to rewrite to remove the warning. Any document to understand how todo. Or new code Thx.

Rails.application.routes.draw do
  post ':controller(/:action(/:id))(.:format)'
  get ':controller(/:action(/:id))(.:format)'
  get '/logout' => 'sessions#destroy', :as => 'logout'
  get '/auth/failure' => 'sessions#failure'
  post '/auth/:provider/callback' => 'sessions#create'
  resources :sessions
  resources :identities
  root :to => 'myapp#index'
end


推荐答案

此处我做了什么。
循环全部得到,感觉就像回到了硬代码。
但是我不知道是否有更好的方法,到目前为止,可以使用Rails 5.2 beta

Here what I did. Loop all get, It's feel like go back to hard code. But I don't know if any way better, So far work with Rails 5.2 beta

Rails.application.routes.draw do
  mount Ckeditor::Engine => '/ckeditor'
  post '/auth/:provider/callback' => 'sessions#create'
  get '/auth/:provider/callback' => 'sessions#create'
  get '/logout' => 'sessions#destroy', :as => 'logout'




  jinda_methods = ['pending','status','search','doc','logs','ajax_notice']
  jinda_methods += ['init','run','run_do','run_form','end_form']
  jinda_methods.each do |aktion| get "/jinda/#{aktion}" => "jinda##{aktion}" end




  post '/jinda/pending' => 'jinda#index'
  post '/jinda/end_form' => 'jinda#end_form'
  get '/articles/my' => 'articles/my'
  resources :articles
  resources :identities
  resources :sessions
  resources :password_resets
  resources :jinda, :only => [:index, :new]
  root :to => 'jinda#index'
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

这篇关于弃用警告:不建议在路线中使用动态:controller区段,并将在Rails 5.1中将其删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆