undefined method `authenticates_with_sorcery!' for User:Class

413 Views Asked by At

ok I'm using sorcery gem for the log in of the main engine. And I want to use it also in the main engine but whenever I call the user model in the mountable engine it says

undefined method `authenticates_with_sorcery!' for User:Class

When I said call it's like

@user = User.new

By the way I'm using mongoid 4.0.0 and rails 4.1

3

There are 3 best solutions below

0
On

In my case, the gems order in the gemfile was apparently wrong

Not good

gem 'sorcery'
gem 'mongoid'

Works!

gem 'mongoid'
gem 'sorcery'
0
On

As far as I remember when I posted this question sorcery gem doesn't support Mongoid 4 yet so they make a new branch in the github so that for those who are using Mongoid in that time can use sorcery with mongoid 4. Well basically the solution works for me is that I need to reference that branch in my Gemfile. I don't know right now if they already publish the latest sorcery gem.

0
On

I ran into similar issues using MongoMapper. Try making sure that authenticates_with_sorcery! appears beneath any of your database-related includes. For example:

class User
  include Mongoid::Document
  authenticates_with_sorcery!


end