AsteriskLabs / devise_google_authenticator

A Devise extension to allow your app to utilise Google's 2FA Mobile app
http://labs.asteriskinfosec.com.au/tag/devise_google_authenticator/
MIT License
216 stars 159 forks source link

mongoid and cancancan: uninitialized constant ActiveRecord::Base (NameError) #49

Open bijrails opened 8 years ago

bijrails commented 8 years ago

Hi,

I'm using mongoid (4.0.2). rails g devise_google_authenticator:install is throwing below error,

/Users/uname/.rvm/gems/ruby-2.1.2/gems/cancancan-1.9.2/lib/cancan/model_adapters/active_record_adapter.rb:146:in `<top (required)>': uninitialized constant ActiveRecord::Base (NameError)

Any idea why install command throwing error ?

Thanks

John-Alves commented 4 years ago

I was facing the same issue when using CanCanCan and Mongoid. I solve it including the Mongoid::Document module on my Ability.rb

Ps: after 4 years, I think you already solve your problem haha. But it may help someone else :D

class Ability
  include Mongoid::Document
  include CanCan::Ability

  def initialize(store)
    # my code
  end
end