在Rails中命名路由的URL

时间:2011-04-24 07:46:00

标签: ruby-on-rails ruby named-routing

HI,

我在生产应用程序中打印指定路径的URL时遇到问题。在我的一个电子邮件模板(电子邮件注册确认)中,我试图附加确认网址。这是模板片段

<p>Welcome to example. To complete your registration, please click on the link below or paste it into a browser to confirm your e-mail address. You will then be redirected to example.com login page </p>

<p> <%= confirmlogin_url(:id => @user.id, :msg =>  @user.verification_code )%> </p>

我的命名路线看起来像这样

 match 'confirm_registration' => 'users#confirm_user' ,:as=> :confirmlogin

它在开发环境中工作正常,电子邮件使用像这样的确认URL进行呈现

Welcome to example. To complete your
registration, please click on the link
below or paste it into a browser to
confirm your e-mail address. You will
then be redirected to example.com.

http://localhost:3000/confirm_registration?id=16&msg=7fe548db-ab7d-3a8d-a87f-94ba89b0c29b

但是在生产环境中,我希望localhost:3000可以替换为我的实际域名。但它仍会打印本地主机网址..

我只想确认这是预期的行为..?

1 个答案:

答案 0 :(得分:1)

将它放到你的production.rb

ActionMailer::Base.default_url_options[:host] = "0.0.0.0:3000"

使用您的主机名。

相关问题