【问题标题】:Rails mailer url_for absolute urlRails 邮件程序 url_for 绝对 url
【发布时间】:2012-05-02 05:58:16
【问题描述】:

Rails 3.2

我正在尝试将 url 添加到链接到用户网站的邮件程序中。 这是我目前拥有的链接:

<%= link_to "Visit our website", url_for(:host => @dealer.stores.first.website) %>

但是,一旦生成了 url,/assets 就会被附加到路径中。 这是生成的 URL:

http://www.foo.com/assets

对于为什么会发生这种情况和/或如何防止添加 /assets 有什么想法吗?

【问题讨论】:

  • 哪个值包含@dealer.stores.first.website
  • 我不确定我是否理解这个问题;但@dealer 在邮件程序中定义(在本例中为customer_mailer.rb 文件)。
  • 你能检查那个值吗? &lt;% Rails.logger.info @dealer.stories.first.website.inspect %&gt;

标签: ruby-on-rails-3 actionmailer


【解决方案1】:

有趣的是,我想我的做法是错误的。我能够让它像这样工作:

<%= link_to "Visit our website", "http://#{@dealer.stores.first.website}" %>

【讨论】:

    猜你喜欢
    • 2011-06-06
    • 2011-05-14
    • 2012-02-13
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多