Forum: Rails Engines is it just me or all all engines links set up as only_path => false ?

Posted by yossarian (Guest)
on 2008-09-28 20:13
(Received via mailing list)
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:

<a href="http://localhost:3005/admin/articles">Back to articles</a>

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

<a href="/admin/articles">Back to articles</a>

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
Posted by yossarian (Guest)
on 2008-09-28 21:14
(Received via mailing list)
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.