I am currently developing against webrick and as such my application
appears under http://localhost:3000/ but in my continuous integration
environment (jruby war deployed to tomcat) the application appears
under http://localhost:8080/myapp
This is a pain when writing Selenium tests because in development I
can use commands such as…
open /foo
… but the ci needs to use …
open /myapp/foo
Note that I think this is a deficiency in the SeleneseAntTask which
accepts a startURL, but … “Note that only the hostname part of this
URL will really be used.”
So… instead I’m wanting a “quick” solution by setting an application
context on webrick.
I thought this was possible just by using …
server.mount( ‘/myapp’, … )
… but when I do this Rails gives me a routing error… eg,
No route matches “/myapp/foo” with {:method=>:get}
So, I’m assuming I’m missing something in my webrick config in order
to mount myapp? … or do I need to add something to routes.rb?
How do I deploy an application to webrick that can then be found under a
specified application context such as localhost:3000/myapp rather than
the default localhost:3000
Add it into config/routes.rb:
map.connect ‘myapp/:controller/:action/:id’
map.connect ‘myapp/:controller/:action/:id.:format’
For mapped resources, use the namespace. Here’s the example in my
routes.rb:
Sample resource route within a namespace:
map.namespace :admin do |admin|
# Directs /admin/products/* to Admin::ProductsController (app/
controllers/admin/products_controller.rb)
admin.resources :products
end
This probably isn’t the “right” way. Another option would be to use
apache to proxy the requests, either proxying and reverse proxying /
myapp to / to webbrick, or proxying and reverse proxying / to /myapp
for tomcat.
How do I deploy an application to webrick that can then be found under a
specified application context such as localhost:3000/myapp rather than
the default localhost:3000
Thanks Kevin, that indeed works on webrick but it does kill the tomcat
version.
No matther though because it can be reconfigured based on environment.
So … Thanks!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.