I need to set up a route that is only valid if the logged in user is admin (user.admin?) using devise. I'm doing this for sidekiq, but the question is valid for any similar use.

Here is my route code:

```
class AdminConstraint
  def matches?(request)
    !request.session['warden.user.user.key'].nil? and request.session['warden'].user.admin?
  end
end

require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new

```

I got this code from the sidekiq wiki: <https://github.com/mperham/sidekiq/wiki/Monitoring>
I tried the code they posted, which didn't work so I made some modifications as I just posted. The code above doesn't work as user evaluates to nil.

What is the correct *secure* way to deal with this?

thanks for any help!