大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 如何在Rails 3中包含全路径link_to语句?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的/ pages / options控制器代码:
class PagesController < ApplicationController def options end end
这里是页面/选项查看:
<div> <%= link_to "here",:controller => "contacts",:action => "confirm",:only_path => false,:id => 17 %> </div>
当我将此链接放入以下邮件程序(welcome_email.html.rb)时,我收到以下错误.对此的任何帮助将不胜感激.
<!DOCTYPE html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> </head> <body> <%= link_to "here",:id => 17 %> </body> </html>
错误信息:
RuntimeError in Contacts#create Showing C:/Documents and SetTings/Corey Quillen/My Documents/Dev/Dev Projects/my_project Project/my_project/app/views/user_R_269_11845@ailer/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: <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> 5: </head> 6: <body> 7: <%= link_to "here",:only_path => false,:id => 17 %> 8: </body> 9: </html>
<%= link_to "here",:id => 17,:host => "example.com" %>
您还可以通过指定以下方式在application.rb(或任何环境)中的每个应用程序的基础上设置默认主机:
config.action_mailer.default_url_options = { :host => "example.com" }
有关ActionMailer的完整文档以及为什么会出现此问题,请查看ActionMailer documentation.
以上是大佬教程为你收集整理的ruby-on-rails – 如何在Rails 3中包含全路径link_to语句?全部内容,希望文章能够帮你解决ruby-on-rails – 如何在Rails 3中包含全路径link_to语句?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。