script/serverto run the app, which makes the application available at
http://localhost:someport. Later, in production it's usually
somedomain.com/. In both cases, the application is mounted at the root of the domain, which means links beginning with
<a href='/users'>Users</a>) which were inadvertently introduced will never break. Then, when someone then deploys your application to a non-root url like
mydomain.com/myappall hell breaks loose and you have a bunch of broken links.
As a preventive measure, it's wiser to both develop and run automated functional test suites (like a Selenium suite) with your application running on a non-root url. That way relative url bugs are caught early enough that nothing significant is affected.
Some ruby servers do indeed support this kind of mounting - but not all, I presume, so
script/serverdoes not support it. However, the popular mongrel server does allow this through the
--prefixoption. We've modified
script/serverto a more narrow
script/mongrelwhich accepts the
--prefixoption and always uses mongrel.
script/mongrelotherwise behaves like
script/serverin every respect.
Try it out - you can get it off GitHub from the script-mongrel project. If you're on Windows (or otherwise don't have git), don't worry - it's a single file plus the README. You can simply copy them off the repo browser.
This issue is finally resolved in Rails 2.3.2; the option there is --path instead of --prefix, e.g.:
ruby script/server -p 3000 --path=/myapp
Newbie here. What's the solution to the relative bug? I've been wanting to get completely relative paths that don't start with a slash out of the link_to and image_tag helpers but can't figure out how. Thanks.
Post a Comment