Rails 5.1 Routes: dynamic :action parameters

前端 未结 3 1680
后悔当初
后悔当初 2021-02-05 09:45

Rails 5.0.0.beta4 introduced a deprecation warning on routes containing dynamic :action and :controller segments:

DEPRECATION WARNING: Using a dynamic :action s         


        
3条回答
  •  滥情空心
    2021-02-05 10:20

    Though it's a bit cumbersome, the best approach seems to be to explicitly define the routes:

    namespace :integrations do
      namespace 'stripe' do
        %w(auth webhook activate).each do |action|
          get action, action: action
        end
      end
      post 'stripe/deactivate', controller: 'stripe', action: 'deactivate'
    end
    

提交回复
热议问题