ruby-on-rails – 如何将rails3路由转换为rails4

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何将rails3路由转换为rails4前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下rails3路由,我想转换为rails4.
map.with_options(:conditions => {:subdomain => AppConfig['admin_subdomain']}) do |subdom|
  subdom.root :controller => 'subscription_admin/subscriptions',:action => 'index'
  subdom.with_options(:namespace => 'subscription_admin/',:name_prefix => 'admin_',:path_prefix => nil) do |admin|
    ...
  end
end

解决方法

namespace :admin do
  constraints subdomain: AppConfig['admin_subdomain'] do
    root to: 'subscription_admin/subscriptions#index'
    namespace :subscription_admin do
      resources :some_resources
        # RESTful routes
      end
    end
  end
end

More info about constrains.

原文链接:https://www.f2er.com/ruby/270244.html

猜你在找的Ruby相关文章