Reputation: 786
I'm using devise_token_auth
to set up authentication for an API-only Rails app. I am testing the registration creation using httpie
at the command line with the following command:
http POST :3000/auth '[email protected]' 'password=password' 'password_confirmation=password'
The response is the full HTML output of the error page, and the error within is wrong number of arguments (given 0, expected 1)
. The offending action is DeviseTokenAuth::RegistrationsController#create
.
Thanks in advance for any guidance. Code is here: https://github.com/jraczak/flow-api
Devise is applied to the User
model: here
Routes is here
Upvotes: 3
Views: 3532
Reputation: 159
If anyone is using Devise Invitable with Devise Token Auth and is getting this error. Check that you are not using Rails in API only mode, specificaly inherating your ApplicationController from ActionController::API instead of ActionController::Base
Upvotes: 1
Reputation: 1
In my current model I already have a password digest. What worked for me was removing the devise: database_authenticatable
from the User model.
Upvotes: 0
Reputation: 3792
Summarising the chat discussion with an answer...
Just remove has_secure_password
in https://github.com/jraczak/flow-api/blob/master/app/models/user.rb and :password_digest
from validates_presence_of :name, :email, :password_digest
...Devise already does that
I see that you already added encrypted_password column in your schema (https://github.com/jraczak/flow-api/blob/master/db/schema.rb) ...In that case remove the password_digest column from the table...It would work
rails g migration RemovePwdDigest
class RemovePwdDigest < ActiveRecord::Migration
def change
remove_column :users, :password_digest
end
end
What might have gone wrong even after removing has_secure_password and validation:
If you see this line, devise tries to call it's internal password_digest method while setting a new password or wherever you use password= method. But, as you already have a db column with name similar to the method (password_digest column), it is calling that instead of devise internal method. So, you are facing an error. (I may be wrong, this alone seems to be suspicious)
Upvotes: 7