jeffl8n
jeffl8n

Reputation: 926

"undefined method `generate_token'" error when trying to manually create a user

When trying to create a new user manually, the error "undefined method `generate_token'" is thrown.

The code doing this worked in previous versions:

user = User.new(email: email, password: Devise.friendly_token[0,20])
user.skip_confirmation!
valid_user = user.save       #<--- error occurs here during .save

I'm using these versions in the Gemfile:

ruby '2.0.0'
gem 'rails', '4.0.0'
gem 'devise', '~> 3.1.1'
gem 'devise_uid', '~> 0.0.3'

The user.rb Devise model has these modules:

devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :lockable, :timeoutable, :uid

Upvotes: 2

Views: 638

Answers (2)

jeffl8n
jeffl8n

Reputation: 926

It turns out the issue was with the devise_uid gem. I created a pull request for it (https://github.com/jingweno/devise_uid/pull/2) and it has already been accepted, so anyone else having this issue should upgrade to 0.0.4.

Upvotes: 2

Yehuda Zargarov
Yehuda Zargarov

Reputation: 277

It seems like this error was fixed lately: See this github issue.

If it still doesn't work, try removing the :rememberable attribute.

Upvotes: 0

Related Questions