RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: jamiecobbett
I wanted only Users with the admin attribute set to true to access resque-web.
Since we're using Devise, the current user is accessible like this:
request.env['warden'].user
So I made the below off the back of the example here: http://www.scottw.com/securing-resque-server-rails-3
require 'resque/server' class SecureResqueServer < Resque::Server before do redirect '/' unless request.env['warden'].user.admin end end
If we were using Devise's "roles" (where each role has it's own table) we could simply do this in the routes file:
authenticate(:admin) do mount Resque::Server, :at => "/resque" end
I wanted only Users with the admin attribute set to true to access resque-web.
Since we're using Devise, the current user is accessible like this:
request.env['warden'].user
So I made the below off the back of the example here:
http://www.scottw.com/securing-resque-server-rails-3
If we were using Devise's "roles" (where each role has it's own table) we could simply do this in the routes file: