JRuby Goldspike in Context Root
If you're using JRuby's Goldspike plugin to create a WAR for deployment, you might discover that rake war:standalone:run puts the application into a named context (e.g. http://localhost:8080/myapplication). Since most Ruby applications run at the root, this might disrupt your application if it wasn't built to handle a changing path (or your remote tests, which might have the same problem).
Fortunately, it's very easy to modify Goldspike to use the root:
- Open vendor/plugins/goldspike/lib/run.rb
- Find the WebAppContext definition
- Adjust the second argument from
<Arg>/<%= config.name %></Arg>
to:
<Arg>/</Arg>
4 comments:
You mention "this might disrupt your application if it wasn't built to handle a changing path"
What do you mean? How could an application be build to handle a changing path?
This is where I show my Ruby ignorance; I have no idea how I'd do this in Ruby on Rails.
In Java web applications, your application is aware of the root of its 'context', and if it always forms links in relationship to that context, you can move it around with relative impunity, without breaking the application itself (although you might still break things that rely on knowledge of where the application is).
I just found that if you use Rails helpers like link_to, image_tag, form_tag, etc, Rails will handle the path correctly whether you are in webrick or tomcat.
Now, I have to find how to handle path to my images hardcoded in my css...
Check out this how-to for a different context-root in rails:
http://snippets.dzone.com/posts/show/3758
(you override an action controller method for relative application root)
Post a Comment