2017-03-16 5 views
-2

routes.rbをしてきたし、古いレール3アプリこの複数ドメインルーティングアプリケーションがすでに使用中、無効なルート名を失敗:「ルート」(例外ArgumentError)

RailsAppli::Application.routes.draw do 
    root :to => "landing#pos", :constraints => { :host => "pos.com.ar" } 

    root :to => "landing#desa", :constraints => { :host => "desa.com.ar" } 

    root :to => "landing#plan", :constraints => { :host => "dise.com.ar" } 

ザッツが正常に動作ようにしかし、私はすでに使用中で、4と

無効なルート名をレールにアップグレード:「ルート」(例外ArgumentError)

いただきました問題。

ありがとうございました。基づいて回答を更新

+0

のアプリのドメインは何ですか? – nateleavitt

答えて

0

Separate Domain for Namespaced Routes in Rails 4

を短縮:

class DomainConstraint 
    def initialize(domain) 
    @domains = [domain].flatten 
    end 

    def matches?(request) 
    @domains.include? request.domain 
    end 
end 

2)を使用してルートでクラスを使用します。

1)のlib/domain_constraint.rbでカスタム制約クラスを定義新しいブロック構文

constraints DomainConstraint.new('mydomain.com') do 
    root :to => 'mydomain#index' 
end 

root :to => 'main#index' 

または古いブロック構文は、形式のオプション構文

root :to => 'mydomain#index', :constraints => DomainConstraint.new('mydomain.com') 
+0

よろしくお願いいたします。しかし、私は別のドメインを私のアプリの特定の着陸に根付かせる必要があります。 pos.com.arと同じようにランディング#po。レール3では、このroutes.rbはレール4ウェイですよね。おかげで – derfarg

+0

ありがとう、しかし、私はドメインが必要です、異なるドメインと1つのアプリケーションは、これらのドメインの異なるランディングページを提供しています。 – derfarg

+0

これを参照してください:http://stackoverflow.com/questions/24122140/separate-domain-for-namespaced-routes-in-rails-4 – nateleavitt

-1

完了!

ルートは1つのみです。

その後、

RailsAppli::Application.routes.draw do 
    get '/', :to => "landing#pos", :constraints => { :host => "pos.com.ar" } 

    get '/', :to => "landing#desa", :constraints => { :host => "desa.com.ar" } 

    get '/', :to => "landing#plan", :constraints => { :host => "dise.com.ar" } 

おかげ

関連する問題