加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – ActionMailer中url_for和命名路由的问题视图:

发布时间:2020-12-17 01:44:18 所属栏目:百科 来源:网络整理
导读:我试图在我的用户欢迎电子邮件中提供确认链接,我收到以下Rails错误: Need controller and action! 它对这一行大惊小怪: pPlease take a moment to activate your account by going to: %= link_to confirm_user_url(:id = @user.confirmation_code) %./p
我试图在我的用户欢迎电子邮件中提供确认链接,我收到以下Rails错误:

Need controller and action!

它对这一行大惊小怪:

<p>Please take a moment to activate your account by going to: 
<%= link_to confirm_user_url(:id => @user.confirmation_code) %>.</p>

在我的development.rb环境中,我有以下几行:

config.action_mailer.default_url_options = {
  :host => "localhost",:port => 3000
}

@user变量没有问题.我用@ user.username和@ user.confirmation_code测试了这封电子邮件.我只是在使用url_for和命名的路由(例如confirm_user_url)时遇到麻烦.

当我使用rake路由检查我的路由时,confirm_user显示出来,因此不存在命名路由不存在的问题.

我似乎无法弄明白.是什么赋予了?

解决方法

由于你的评论中有一个可点击的网址就是你所说的,所以你去macek

<p>Please take a moment to activate your account by going to: 
<%= auto_link confirm_user_url(:id => @user.confirmation_code) %>.</p>

我已经在我的一些邮件中使用了auto_link帮助程序来使网址可以点击,而且效果非常好.我认为这也是电子邮件地址,请查看所有选项的完整API.请享用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读