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=username@email.com' '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
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)