2015-08-18 81 views
1

比方說,我有一個郵件程序,它是從應用程序中的多個位置觸發的,它使用引用應用程序URI的I18n鍵。像這樣:Rails I18n訪問路徑幫助程序

mailers: 
    congratulations: "Congratulations! Go to https://www.example.com to claim your prize!" 

因爲我從多個位置訪問它,所以我不想將URI傳遞給I18n調用。

如果我有多種語言的此消息,所有引用相同的URI,如何將該URI的變量傳遞給消息,如路徑助手?

回答

1

你可以把URI在application.rb中,你可以訪問它爲MyAppName::Application::YOUR_URI

congratulations: "Congratulations! Go to #{MyAppName::Application::YOUR_URI} to claim your prize!" 
+0

是的,這是可行的。這不是存儲URI的好地方,但我明白你的觀點。你有任何想法訪問路徑助手本身? – steel

+0

是的,你可以訪問路徑助手作爲'Rails.application.routes.url_helpers.ur_path' – mudasir

+0

和url:'Rails.application.routes.url_helpers.your_url' – mudasir