Rails アプリケーションでいくつかの変換ルートを定義してみます。サブドメインの定義でルートが変わります。だから私はこの結果が欲しい:
describe "url_for" do
context 'with en' do
it 'brand translate' do
url_for(
:controller => 'boats',
:action => 'index',
:subdomain => :en,
:brand => 'hello',
:only_path => true
).should == '/yacht-charter/brand-hello'
end
end
context 'with fr' do
it 'brand translate' do
url_for(
:controller => 'boats',
:action => 'index',
:subdomain => :fr,
:brand => 'hello',
:only_path => true
).should == '/location-bateau/marque-hello'
end
end
end
ご覧のとおり、両方の url_for パラメータ間の唯一の変更点はサブドメインです。私は試します:
constraints => :subdomain => :en do
match '/yacht-charter/brand-:brand' => 'boats#index', :as => 'en_brand_search'
end
constraints :subdomain => :fr do
match '/location-bateau/marque-:brand' => 'boats#index', :as => 'fr_brand_search'
end
しかし、常にそれが使用する最初のルート定義です。2 番目は決して定義されません。
どうやってやるの。それはレールのバグですか?