2014-01-24 53 views
1

我有以下的在我的routes.rb定義Rails 3的可選範圍URL生成

scope '(:subdomain)' do 
    resource :highscore 
end 

現在我可以對這些路徑到達同一個資源

/highscore 
/test/highscore 

然而,當我生成一個URL使用

highscore_path 

它將始終生成/ highscore路徑,但是,我希望它生成一個/ test/highs當測試子域

內我試圖操縱default_url_options或

highscore_path(:subdomain => 'test') 

但它總是省略了測試芯路徑。我如何解決這個問題,最好不必更改所有的url?

回答

1

原來,符「子域」是愚蠢:(替換成別的,它會努力!

我在application_controller覆蓋default_url_options與

def default_url_options 
    return {:identifier => 'test'}.merge(super) 
end 
+0

你應該接受你的答案,還是你在等待更多? – rlecaro2