Skip to content

Instantly share code, notes, and snippets.

@neovintage
Created December 11, 2011 10:59
Show Gist options
  • Save neovintage/1459949 to your computer and use it in GitHub Desktop.
Save neovintage/1459949 to your computer and use it in GitHub Desktop.
Mounting Resque Server to Rails 3 with Devise and Warden
class Awesomeapp::Resque < Resque::Server
# Will redirect back to rails app to require a sign in
before do
env['warden'].authenticate!
end
end
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
# old way of doing it
# run Awesomeapp::Application
map '/' do
run Awesomeapp::Application
end
map '/resque' do
# key in initializers/session_store.rb
# secret in initializers/secret_token.rb
# We're doing this so that the same cookie is used across
# Resque Web and the Rails App
use Rack::Session::Cookie, :key => '_awesomeapp_session',
:secret => Awesomeapp::Application.config.secret_token
# Typical warden setup but instead of having resque web handle
# failure, we'll pass it off to the rails app so that devise
# can take care of it.
use Warden::Manager do |manager|
manager.failure_app = Awesomeapp::Application
manager.default_scope = Devise.default_scope
end
# what the heck is this??
run Awesomeapp::Resque
end
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Awesomeapp::Application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment