1

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
PKul
  • 1,691
  • 2
  • 21
  • 41
  • Possible duplicate of [Rails 5.1 Routes: dynamic :action parameters](https://stackoverflow.com/questions/37008713/rails-5-1-routes-dynamic-action-parameters) – 3limin4t0r Sep 19 '17 at 12:43
  • What the new rewrite of "post ':controller(/:action(/:id))(.:format)' get ':controller(/:action(/:id))(.:format)' "? – PKul Sep 20 '17 at 11:18
  • From surfing on the internet it seems to my that dynamic actions/controllers are phased out and there is no alternative. I imagine it has to do with the security of the application. The best solution I found so far is just whitelist all action, thus writing them all out, or looping through them, like shown in the answer of the duplicate question. – 3limin4t0r Sep 21 '17 at 09:52
  • See: https://github.com/rails/rails/pull/23980 – 3limin4t0r Sep 21 '17 at 09:59
  • And: https://github.com/rails/rails/issues/27231, @TheR2 (in the issue) has a workaround for `:action`, with some searching maybe this can be done for `:controller` as well. – 3limin4t0r Sep 21 '17 at 10:58
  • Still confuse for me and don't know how to rewrite/replace post ':controller(/:action(/:id))(.:format)' get ':controller(/:action(/:id))(.:format)' – PKul Oct 13 '17 at 00:11

1 Answers1

0

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
PKul
  • 1,691
  • 2
  • 21
  • 41