RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: ciscoriordan
Thanks. If you use .try(:admin) instead, the redirect works correctly even if you aren't logged in:
require 'resque/server' class Resque::SecureResqueServer < Resque::Server before do redirect '/' unless request.env['warden'].user.try(:admin) end end
That also uses the Resque:: namespace and is loaded by Rails automatically if you use it in e.g. app/initializers/resque_auth.rb.
In your routes.rb, you would include:
mount Resque::SecureResqueServer, :at => "/resque"
Thanks. If you use .try(:admin) instead, the redirect works correctly even if you aren't logged in:
That also uses the Resque:: namespace and is loaded by Rails automatically if you use it in e.g. app/initializers/resque_auth.rb.
In your routes.rb, you would include: