dimas priyanto - a guy with mouse and keyboard

adding routes to non-rails mounted application

Written on August 28, 2011

I think many people will find what i had just encountered. Yea, i was so confused to embed resque’ path inside rails routes, so when i request to my-app.com/resque it will load up resque-web interface. Following a presentation on railscasts i can use:

mount Resque::Server, :at => ‘/resque’

But it’s conflicted with customized flash session on the application, and when i it got resolved, then it’s conflicted with devise, getting NoMethodError: undefined method new__session_path.

So, i think i should mount it without loading any rack environment, and the idea is embed it inside config.ru file, here is:

require ‘resque/server’

if you want to add http basic authentication, add this lines:

Resque::Server.use(Rack::Auth::Basic) do |username, password|
password == ‘youremonkey’ #no offensive if you are actually monkey, hehe
end

and mount them together:

run Rack::URLMap.new(‘/’ => Rails::Application, ‘/resque’ => Resque::Server.new)

and they’re should working together smoothly

Tags: , , ,