views:

20

answers:

1

So the consensus seems to be that in order to get URLs working in the emails your application sends, you have to set config.action_mailer.default_url_options.

This is well and good if you're using whatever_url or url_for, but what if there's some helper or partial that you want to use to generate an email that uses whatever_*path*, e.g., song_path(:song_slug => song, :artist_slug => song.artist)?

How can I use such a helper in an email template without changing all these url-generating methods? Also, I thought using whatever_path instead of whatever_url was considered a best practice. If whatever_path is useless for email though, should I start using whatever_url everywhere in my application?

A: 

No... Its ok and best practice to use asdasdad_path's, because they create relative paths.

asdasd_url's produces the absolute urls -> Your browser knows how to cope with relative paths, but how should that work in emails?

There is noch chance in your email to refer to a base-path(f.e. domain).

So you should use paths in your application and urls in email.

Lichtamberg
Did that help you?
Lichtamberg