cancan_devise_rails_admin not working

I am using mongoid, cancan, devise, rails_admin combination. each of them works individually, however when I set an admin boolean attribute of user, and set various places follow the tutorial, it did not work, here is all the related code snippet:

Gemfile ... gem 'rails_admin', :git => 'git://' gem 'cancan'


class User ... # user.admin? works by setting the following field :admin, type: Boolean, default: false



RailsAdmin.config do |config| ... config.authorize_with :cancan ... end


class Ability   include CanCan::Ability   def initialize(user)     can :read, :all     if user && user.admin?       can :access, :rails_admin     end   end end

However when I access the localhost:3000/admin, with a user with its admin attribute set to true, I got this:

Started GET "/admin" for at 2012-03-22 19:59:26 -0500 Processing by RailsAdmin::MainController#dashboard as HTML MONGODB (0ms) testapp_development['users'].find({:_id=>BSON::ObjectId('4f6932751d4ee83acb000002')}).limit(-1).sort([[:_id, :asc]]) Completed 500 Internal Server Error in 6ms

CanCan::AccessDenied (You are not authorized to access this page.):   cancan (1.6.7) lib/cancan/ability.rb:202:in `authorize!'   /home/baboonworksfine/.rvm/gems/ruby-1.9.3-p0@rails320/bundler/gems/rails_admin-7a4fdd931f95/lib/rails_admin/extensions/cancan/authorization_adapter.rb:21:in `authorize'   activesupport (3.2.0) lib/active_support/core_ext/object/try.rb:32:in `try'   (eval):4:in `dashboard'   actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'   actionpack (3.2.0) lib/abstract_controller/base.rb:167:in `process_action'   actionpack (3.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action' ... ... ...