如何在Rails 3的link_to语句中包含完整路径?
如何在Rails 3的link_to语句中包含完整路径?
我试图将一个Rails的link_to语句放在一个Mailer邮件中,其中包含完整路径(即- http://localhost/contacts/id/confirm)。我尝试的link_to语句在我的标准视图/pages/options中可以工作,但在Mailer邮件中却不起作用。
这是我的/pages/options控制器代码:
class PagesController < ApplicationController def options end end
以下是pages/options视图:
<%= link_to "here", :controller => "contacts", :action => "confirm", :only_path => false, :id => 17 %>
当我将这个链接放入以下邮件(welcome_email.html.rb)中时,我遇到了下面的错误。非常感谢您提供的任何帮助。
<%= link_to "here", :controller => "contacts", :action => "confirm", :only_path => false, :id => 17 %>
错误信息:
RuntimeError in Contacts#create Showing C:/Documents and Settings/Corey Quillen/My Documents/Dev/Dev Projects/my_project Project/my_project/app/views/user_mailer/welcome_email.html.erb where line #7 raised: Missing host to link to! Please provide :host parameter or set default_url_options[:host] Extracted source (around line #7): 4: 5: 6: 7: <%= link_to "here", :controller => "contacts", :action => "confirm", :only_path => false, :id => 17 %> 8: 9: