Is it just me or all all engines links set up as only_path => false?


#1

Hi there,

Is it the case that all links in engines seem to ignore the default
Rails only_path => false option? Every link_to in my Engine results in
links like:

Back to articles

whereas the non-engine views in the same application result in links
like:

Back to articles

This is a big problem for me because I’m using Rails full-page caching
on a site which can be accessed via either http or https, and the cache
files are getting written to disk with the full https:// which is real
ugly for what I’m trying to do.

Explicitly setting
ActionController::UrlWriter.default_url_options[:only_path] = true
doesn’t seem to help anything, and I can’t see anything in the Engines
plugin that’s explicitly causing this.

Is this behaviour intentional, am I doing something really wrong, or is
there a configuration option I can set somewhere?

Greets,
Yossarian


#2

yossarian wrote:

Is this behaviour intentional, am I doing something really wrong, or is
there a configuration option I can set somewhere?

The answer: choice (b), I was doing something really wrong. I
investigated things further, and I came to the conclusion that whatever
was causing my problem had to do with actioncontroller routing - I
noticed that routes in my engine were all absolute when I used the named
routes from my resources in the engines routes.rb, but not when I
generated named routes myself using something like:

map.foo ‘foo/bar’, :controller => ‘admin/articles’

So I looked a little harder into the Engines routing.rb file, which led
me to actually read the source code of
ActionController::Routing::RouteSet for the first time. I never really
understood before why there was an articles_url(article) and
articles_path(article) but now I realize that the _url is for a url and
the _path is for a path. Now I will go hang my head in shame :).

By the way, Engines are pretty great, and have really helped me do the
stuff I want to accomplish, so thanks for the plugin!

Yossarian