Note that there are some explanatory texts on larger screens.

plurals
  1. POCamping's URL() doesn't give me "site root" as expected?
    text
    copied!<p>Due to circumstances beyond my control, my production Camping site appears at <code>mysite.example.com/mysite</code>. I'm pretty sure this is a common Apache / Passenger configuration issue, and I'm not interested in how to fix it right now because the server is out of my control. Suffice to say, the controller for "/" points there and I can't change that any time soon.</p> <p>Now, for a long time, this wasn't an issue, because <code>R(MyIndexController)</code> points to the correct place. However, I serve my site's CSS using a <code>Rack::Static</code> call to make $SITE_ROOT/public accessible. This means that the stylesheet is at <code>mysite.example.com/mysite/css/style.css</code>. Here's where the problem comes in: the Camping <code>URL()</code> method, when called in my layout, gives <code>http://mysite.example.com</code>, not <code>http://mysite.example.com/mysite</code>. So I can't get it to point to the /css subdirectory, because it's missing a "hop" in the middle. When I run rackup locally, everything is fine (because this file is at <code>localhost:8080/css/style.css</code>), but on the production server I don't know how to fix it.</p> <p>My question: is there another method (maybe directly from Rack?) that I should be calling instead? I really want to avoid hardcoding it, and/or having a hack to determine whether I'm running locally (for debug) or in production, for every rendering of the layout.</p> <p>ETA: OK, this gets stranger. Obviously I've abstracted out some of the actual details above, part of which I think I "over-scrubbed". The "top level" URL is actually more akin to <code>/mysite/rest</code> (the developer-centric HTML presentation of our RESTful interface), as opposed to <code>/mysite/management</code> (accounts) or <code>/mysite/ui</code> (JQuery'd / "nice" UI). These are set up in our config.ru, via <code>run Rack::URLMap.new(Hash['/rest' =&gt; RestModule, '/ui' =&gt; PrettyInterfaceModule, '/management' =&gt; UserManagerModule]</code>, etc.</p> <p>So in answer to the comment below, R(Index), from a view in the RestModule, actually returns <code>/mysite/rest/</code>. As an example, I have a "home" link in the layout, which looks like <code>a :href=&gt;R(Index)</code>, and generates code that looks like <code>&lt;a href="/mysite/rest/"&gt;</code>. The server is configured to serve files from ./public directly at the "site root", so <code>./public/css/style.css</code> actually does apppear at <code>http://mysite.example.com/mysite/css/style.css</code>, as noted previously. It's <em>that</em> link that I'm having trouble automatically generating, and it's because of the Rack::URLMap that I thought I may have to rely on a native Rack method (not a Camping abstraction) to locate this resource.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload