Whenever one of the mailers fires off if the body contains something like link_to root_url
it gives this incredibly unhelpful error:
ActionView::Template::Error: No route matches {}
The trace either is useless or points to that link_to
method. Since it's also very unsearchable here I am asking on stack overflow.
UPDATE 1: To help, I've posted the terrifying routes.rb
file: https://gist.github.com/2955610
UPDATE 2: In the console, app.root_url
provides the correct return.
UPDATE 3: link_to "whatever", root_url
works just fine. So strange!
UPDATE 4: It works fine in a regular rails view.
UPDATE 5: FIXED The image_tag
now isn't providing a host in the email, outputting: http://assets/...png
. Fffff.
UPDATE 6: I've narrowed it down to that I get the same error with (in console) app.url_for
. I think it may be related.
So the real answer is that link_to
works differently in ActionMailer than in ActionController. The difference is that apparently ActionController has an option called :script_name
, and this makes all sorts of assumptions for you.
Now while I don't agree with that difference there's not much you can do about it, so here's what I ended up doing:
link_to root_url, root_url
Now, why would I use both? Well two reasons:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With