0

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

特定のEmail.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

そして、SHOULDは次のとおりです。

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)
4

1 に答える 1

0

これはルーティングの問題である可能性があります。一般に、特定のリソースにリンクしている場合は、コレクション メソッドではevent_url(@comment.event)なくメンバー メソッドが必要になります。events_url

于 2013-04-09T09:32:40.013 に答える