Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 发送电子邮件时URL格式错误。轨道3.2_Ruby On Rails_Ruby On Rails 3_Email_Actionmailer_Link To - Fatal编程技术网

Ruby on rails 发送电子邮件时URL格式错误。轨道3.2

Ruby on rails 发送电子邮件时URL格式错误。轨道3.2,ruby-on-rails,ruby-on-rails-3,email,actionmailer,link-to,Ruby On Rails,Ruby On Rails 3,Email,Actionmailer,Link To,我已经成功地从我的Rails 3.2应用程序发送电子邮件(gmail),没有明显的问题。但是,电子邮件中生成的URL错误地定位了:id参数 通知邮递员 default :from => 'no-reply@someDomaiin.com' def report_spam(comment) @comment = comment mail(:to => "admin@someDomaiin.com", :subject => "Inappropriate cont

我已经成功地从我的Rails 3.2应用程序发送电子邮件(gmail),没有明显的问题。但是,电子邮件中生成的URL错误地定位了:id参数

通知邮递员

default :from => 'no-reply@someDomaiin.com'
def report_spam(comment)
    @comment = comment

    mail(:to => "admin@someDomaiin.com", :subject => "Inappropriate content report")
  end
certainEmail.html.haml

Reported by:
"
= link_to @comment.reports.last.user.name, users_url(@comment.reports.last.user)
"
%p

Content of the accused comment:
%br
"
= link_to @comment.body, events_url(@comment.event.id)
"
%p
收件箱里的电子邮件看起来不错

Reported by: " saben "
Content of the accused comment: 
" I just created a superb event!! "
但是,这两个链接URL都是:

http://someDomaiin.heroku.com/saben/users
http://someDomaiin.heroku.com/2/events
而最重要的是:

http://someDomaiin.heroku.com/users/saben
http://someDomaiin.heroku.com/events/2
我收到的所有/不同的邮件都会发生这种情况。我有什么明显的遗漏吗

提前谢谢

解决方案:

= link_to @comment.reports.last.user.name, user_url(:id => @comment.reports.last.user.id)
"
%p

Content of the accused comment:
%br
"
= link_to @comment.body, event_url(:id => @comment.event.id)

这可能是一个路由问题,一般来说,如果要链接到特定资源,则需要使用成员方法
event\u url(@comment.event)
,而不是
events\u url
,后者是一种收集方法