I am trying to create a devise user via a post request to my rails api. When i submit the request, I get the following message back :
<h2>Sign up</h2>
<form class="new_user" id="new_user" action="/users" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="✓" /><input type="hidden" name="authenticity_token" value="aD/tTW9DM0nXQap07ZAH6U5Uu/YP2hUA+ThM28VGKKjuZJuJw6c2JbYK6m4T737d7ue9S4RIlP1s7Y4xcMgy/g==" />
<div id="error_explanation">
<h2>
2 errors prohibited this user from being saved:
</h2>
<ul>
<li>Email can't be blank</li>
<li>Password can't be blank</li>
</ul>
</div>
<div class="field">
<div class="field_with_errors"><label for="user_email">Email</label></div><br />
<div class="field_with_errors">
<input autofocus="autofocus" autocomplete="email" type="email" value="" name="user[email]" id="user_email" /></div>
</div>
<div class="field">
<div class="field_with_errors"><label for="user_password">Password</label></div>
<em>(6 characters minimum)</em>
<br />
<div class="field_with_errors">
<input autocomplete="new-password" type="password" name="user[password]" id="user_password" /></div>
</div>
<div class="field">
<label for="user_password_confirmation">Password confirmation</label><br />
<input autocomplete="new-password" type="password" name="user[password_confirmation]" id="user_password_confirmation" />
</div>
<div class="actions">
<input type="submit" name="commit" value="Sign up" data-disable-with="Sign up" />
</div>
</form>
<a href="/users/sign_in">Log in</a><br />
here is the data I am sending in my request, which I am making via Postman: http://localhost:3001/users/?email=testacct@yahoo.com&password=testpass
I have also tried sending the request with uppercase Email and Password fields
server logs:
app/controllers/users/registrations_controller.rb:23:in `create'
Started POST "/users/?email=testacct@yahoo.com&password=[FILTERED]" for ::1 at 2019-07-16 17:13:55 -0400
Processing by Users::RegistrationsController#create as */*
Parameters: {"email"=>"testacct@yahoo.com", "password"=>"[FILTERED]"}
(0.2ms) BEGIN
↳ app/controllers/users/registrations_controller.rb:16
User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", ""], ["LIMIT", 1]]
↳ app/controllers/users/registrations_controller.rb:16
(0.2ms) ROLLBACK
↳ app/controllers/users/registrations_controller.rb:16
Rendering /Users/.rvm/gems/ruby-2.6.1/gems/devise-4.6.2/app/views/devise/registrations/new.html.erb
Rendered /Users/.rvm/gems/ruby-2.6.1/gems/devise-4.6.2/app/views/devise/shared/_error_messages.html.erb (1.0ms)
Rendered /Users/.rvm/gems/ruby-2.6.1/gems/devise-4.6.2/app/views/devise/shared/_links.html.erb (0.8ms)
Rendered /Users/.rvm/gems/ruby-2.6.1/gems/devise-4.6.2/app/views/devise/registrations/new.html.erb (7.0ms)
Completed 200 OK in 34ms (Views: 9.2ms | ActiveRecord: 5.5ms)
I was able to fix this by adding:
respond_to :json
to the application controller and removing all extra devise params sanitizers i had added. Additionally i added devise-token-auth gem and used that to set up my user routes