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

旧巷老猫 提交于 2019-12-11 04:55:37

问题


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.

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

回答1:


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


来源:https://stackoverflow.com/questions/42189835/deprecation-warning-using-a-dynamic-controller-segment-in-a-route-is-deprecate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!