Имаме приложение, което се обновява от Rails 3.2 до 4.0.
Версията 3.2 roots
всички над routes.rb, които аз пренесени на новия синтаксис, но аз не съм съвсем сигурен как да се справят с ограниченията на поддомейна.
В 3.2:
constraints(SubDomain) do
root to: "companies#index"
...
end
Опитах се да го прехвърля като други коренови пътеки, но изглежда, че е налице конфликт на непроменения коренов път.
Ето какво опитах:
constraints(SubDomain) do
get "/", to: "companies#index", as: :root
...
end
И грешката:
/Users/blu/.rvm/gems/ruby-2.1.7/gems/actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:430:in
add_route": Invalid route name, already in use: "root" (ArgumentError) You may have defined two routes with the same name using the
:катоoption, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with
ресурсиas explained here: http://guides.rubyonrails.org/routing.html#restricting-the-routes-created from /Users/blu/.rvm/gems/ruby-2.1.7/gems/actionpack-4.0.13/lib/action_dispatch/routing/mapper.rb:1484:in
add_route "
Всяка помощ за правилния синтаксис тук ще бъде страхотно, благодаря.
Отговори:
0 за отговор № 1Разрешете конфликта, като посочите друго име
constraints(SubDomain) do
root :to => "companies#index", :as=> :subdomain_root
...
end