A legacy application with a strange routing error. No route matches {}

Whenever one of the email programs fires, if the body contains something like link_to root_url, it gives this incredibly useless error:

ActionView::Template::Error: No route matches {}

Tracing is either useless or points to this method link_to. Since it is also very incomprehensible here, I ask about stack overflow.

UPDATE 1: To help, I sent a terrible routes.rbfile: https://gist.github.com/2955610

UPDATE 2: The console app.root_urlreturns the correct result.

UPDATE 3: link_to "whatever", root_url works fine. So strange!

UPDATE 4: It works fine in normal rail viewing mode.

UPDATE 5: FIXED. image_tagno longer provides the host in a letter that displays: http://assets/...png. FFFFF.

UPDATE 6: I narrowed it down to getting the same error from (in the console) app.url_for. I think this may be related.

+5
source share
2 answers

So, the real answer is that it link_toworks differently in ActionMailer than in ActionController. The difference is that, apparently, the ActionController has an option :script_name, and that makes all kinds of assumptions for you.

Now that I do not agree with this difference, you cannot help it, so here is what I did:

link_to root_url, root_url

Now, why should I use both? Well, two reasons:

  • I need a url like anchor text and href.
  • URL- , .
+6

, , , "host"?:)

0

All Articles