【问题标题】:named route's URL in RailsRails 中命名路由的 URL
【发布时间】:2011-04-24 07:45:59
【问题描述】:

嗨,

我在生产应用程序中打印命名路由的 URL 时遇到问题。在我的一个电子邮件模板(电子邮件注册确认)中,我试图附加确认 url。这是模板 sn-p

<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 替换为我的实际域名。但它仍然会打印本地主机 url..

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

【问题讨论】:

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


    【解决方案1】:

    把它放到你的production.rb中

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

    使用您的主机名。

    【讨论】:

      猜你喜欢
      • 2015-04-15
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多