devise_token_auth in --api application - sign_in action doesn't work after second deploy on heroku

Hello,

I’ve the question about the “devise_token_auth” gem, authentication in Ruby on Rails application (API) and deploying it to Heroku.

Introduction

What I did:

1/ Created an --api --database=postgresql app

2/ Added some required gems like

gem ‘devise_token_auth’
gem ‘omniauth’
gem ‘rack-cors’, :require => ‘rack/cors’

``

3/ Added CORS

4/ Added User model

rails generate devise_token_auth:install User auth

``

and modified my class definition

class User < ActiveRecord::Base
devise :database_authenticatable,
:registerable,
:recoverable,
:rememberable,
:trackable,
:validatable,
:omniauthable
include DeviseTokenAuth::Concerns::User
end

``

5/ Added the following statement into the seed.rb file

User.create(email: ‘user@example.com’, nickname: ‘UOne’, name: ‘User One’, password: “monkey67”)

``

6/ Initialized git repo, pushed it, initialized heroku app and pushed this app using the commands:

heroku signin
heroku keys:add
heroku create
git push heroku master
heroku run rake db:create
heroku run rake db:migrate
heroku run rake db:seed

``

So, this was the first deploy. Everything works as expected. When I send a request using RESTclient in firefox:

Request type: POST on “https://myapp.herokuapp.com/auth/sign_in
Content-Type: application/x-www-form-urlencoded; charset=utf-8

Body: email=user%40example.com&password=monkey67

``

I got the response 200(OK) with the token. It is OK.

Further steps are:

7/ Added a new user in seed.rb file, the new file looks as follows

User.create(email: ‘user@example.com’, nickname: ‘UOne’, name: ‘User One’, password: “monkey67”)
User.create(email: ‘user2@example.com’, nickname: ‘UTwo’, name: ‘User two’, password: “monkey69”)

``

8/ Pushed the changes to git repo and then to heroku


git push
git push heroku master
heroku run rake db:seed

``

The problem

When I send a request using RESTclient in firefox for the new user:

Request type: POST on “https://hereismyapp.herokuapp.com/auth/sign_in
Content-Type: application/x-www-form-urlencoded; charset=utf-8

Body: email=user2%40example.com&password=monkey69

``

I got the response 200(OK) with the token. It is OK.

The part of heroku logs for the second user

Started POST “/auth/sign_in” for 94.254.189.86 at 2017-05-18 21:09:33 +0000
User Load (1.1ms) SELECT “users”.* FROM “users” WHERE (email = ‘user2@example.com’ AND provider=‘email’) ORDER BY “users”.“id” ASC LIMIT $1 [[“LIMIT”, 1]]
Processing by DeviseTokenAuth::SessionsController#create as /
Parameters: {“email”=>“user2@example.com”, “password”=>"[FILTERED]"}

Completed 200 OK in 492ms (Views: 0.5ms | ActiveRecord: 36.8ms)
at=info method=POST path="/auth/sign_in" host=hereismyapp.herokuapp.com request_id=df397a4c-ea1e-4c90-8d40-f2382dfab1f8 fwd=“94.254.189.86” > dyno=web.1 connect=3ms service=500ms status=200 bytes=580 protocol=https

``

However, when I do the same thing for the old user that was in my seed.rb file from the beginning the response code is 500 (Internal server error).

I would like to say that both records are in my db on heroku.

The part of heroku logs for the first user

Started POST “/auth/sign_in” for 94.254.189.86 at 2017-05-18 21:09:43 +0000
User Load (1.0ms) SELECT “users”.* FROM “users” WHERE (email = ‘user@example.com’ AND provider=‘email’) ORDER BY “users”.“id” ASC LIMIT $1 [[“LIMIT”, 1]]
IndexError (string not matched):
at=info method=POST path="/auth/sign_in" host=hereismyapp.herokuapp.com request_id=f2e57933-1220-4e55-9554-2496638a1c9f fwd=“94.254.189.86” dyno=web.1 connect=1ms service=162ms status=500 bytes=189 protocol=https

``

How to resolve this issue?

I had to clean my db on heroku using the commands

heroku pg:reset DATABASE
heroku run rake db:migrate

``

The main question

Why do I have to clean my database using pg:reset command to make my api work for the all data. Why is that? Is it the correct behaviour?

IndexError (string not matched) is not a database error. Your data is probably fine, but you can run heroku run console and check your user records.

IndexError often comes up when your code treats a string as a hash, but there isn’t enough information here to see what’s going on. Is there a stack trace in the logs?

See this post too http://stackoverflow.com/a/2072348/1438490

I think that my db is OK.
Take a look please:

heroku run console
User.where(email: ‘user@example.com’, provider: ‘email’)

D, [2017-05-20T10:43:39.855948 #4] DEBUG – : User Load (1.6ms) SELECT “users”.* FROM “users” WHERE “users”.“email” = $1 AND “users”.“provider” = $2 [[“email”, “user@example.com”], [“provider”, “email”]]
=> #<ActiveRecord::Relation [#<User id: 1, provider: “email”, uid: “user@example.com”, name: “User One”, nickname: “UOne”, image: nil, email: “user@example.com”, created_at: “2017-05-20 10:05:39”, updated_at: “2017-05-20 10:29:25”>]>

``

Sir, what do you mean stack tracke? As I understood correctly I should print out the full logs report, right?

2017-05-20T10:52:18.126163+00:00 app[web.1]: I, [2017-05-20T10:52:18.126049 #4] INFO – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] Started POST “/auth/sign_in” for 159.205.203.189 at 2017-05-20 10:52:18 +0000
2017-05-20T10:52:18.127182+00:00 app[web.1]: I, [2017-05-20T10:52:18.127110 #4] INFO – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] Processing by DeviseTokenAuth::SessionsController#create as HTML
2017-05-20T10:52:18.127236+00:00 app[web.1]: I, [2017-05-20T10:52:18.127186 #4] INFO – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] Parameters: {“email”=>“user@example.com”, “password”=>"[FILTERED]"}
2017-05-20T10:52:18.285137+00:00 app[web.1]: I, [2017-05-20T10:52:18.284972 #4] INFO – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] Completed 500 Internal Server Error in 158ms (ActiveRecord: 1.0ms)
2017-05-20T10:52:18.130991+00:00 app[web.1]: D, [2017-05-20T10:52:18.130911 #4] DEBUG – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] User Load (1.0ms) SELECT “users”.* FROM “users” WHERE (email = ‘user@example.com’ AND provider=‘email’) ORDER BY “users”.“id” ASC LIMIT $1 [[“LIMIT”, 1]]
2017-05-20T10:52:18.286563+00:00 app[web.1]: F, [2017-05-20T10:52:18.286504 #4] FATAL – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] IndexError (string not matched):
2017-05-20T10:52:18.286498+00:00 app[web.1]: F, [2017-05-20T10:52:18.286429 #4] FATAL – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70]
2017-05-20T10:52:18.286744+00:00 app[web.1]: F, [2017-05-20T10:52:18.286654 #4] FATAL – : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/devise_token_auth-0.1.42/app/controllers/devise_token_auth/sessions_controller.rb:42:in []=' 2017-05-20T10:52:18.286620+00:00 app[web.1]: F, [2017-05-20T10:52:18.286562 #4] FATAL -- : [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] 2017-05-20T10:52:18.286746+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/devise_token_auth-0.1.42/app/controllers/devise_token_auth/sessions_controller.rb:42:in create’
2017-05-20T10:52:18.286747+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal/basic_implicit_render.rb:4:in send_action' 2017-05-20T10:52:18.286749+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/abstract_controller/base.rb:188:in process_action’
2017-05-20T10:52:18.286750+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal/rendering.rb:30:in process_action' 2017-05-20T10:52:18.286751+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/abstract_controller/callbacks.rb:20:in block in process_action’
2017-05-20T10:52:18.286752+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:126:in call' 2017-05-20T10:52:18.286753+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:506:in block (2 levels) in compile’
2017-05-20T10:52:18.286754+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:455:in call' 2017-05-20T10:52:18.286755+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:101:in run_callbacks
2017-05-20T10:52:18.286756+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:750:in _run_process_action_callbacks' 2017-05-20T10:52:18.286757+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:90:in run_callbacks’
2017-05-20T10:52:18.286758+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/abstract_controller/callbacks.rb:19:in process_action' 2017-05-20T10:52:18.286759+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal/rescue.rb:20:in process_action’
2017-05-20T10:52:18.286760+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal/instrumentation.rb:32:in block in process_action' 2017-05-20T10:52:18.286760+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/notifications.rb:164:in block in instrument’
2017-05-20T10:52:18.286761+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/notifications/instrumenter.rb:21:in instrument' 2017-05-20T10:52:18.286762+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal/instrumentation.rb:30:in process_action’
2017-05-20T10:52:18.286762+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/notifications.rb:164:in instrument' 2017-05-20T10:52:18.286763+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal/params_wrapper.rb:248:in process_action’
2017-05-20T10:52:18.286764+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.3/lib/active_record/railties/controller_runtime.rb:18:in process_action' 2017-05-20T10:52:18.286765+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/abstract_controller/base.rb:126:in process’
2017-05-20T10:52:18.286765+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal.rb:190:in dispatch' 2017-05-20T10:52:18.286766+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_controller/metal.rb:262:in dispatch’
2017-05-20T10:52:18.286767+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/routing/route_set.rb:50:in dispatch' 2017-05-20T10:52:18.286767+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/routing/route_set.rb:32:in serve’
2017-05-20T10:52:18.286768+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/routing/mapper.rb:16:in block in <class:Constraints>' 2017-05-20T10:52:18.286773+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/journey/router.rb:39:in block in serve’
2017-05-20T10:52:18.286772+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/routing/mapper.rb:46:in serve' 2017-05-20T10:52:18.286774+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/journey/router.rb:26:in each’
2017-05-20T10:52:18.286774+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/journey/router.rb:26:in serve' 2017-05-20T10:52:18.286775+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/routing/route_set.rb:725:in call’
2017-05-20T10:52:18.286776+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/rack-cors-0.4.1/lib/rack/cors.rb:81:in call' 2017-05-20T10:52:18.286776+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/warden-1.2.7/lib/warden/manager.rb:36:in block in call’
2017-05-20T10:52:18.286777+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/warden-1.2.7/lib/warden/manager.rb:35:in catch' 2017-05-20T10:52:18.286778+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/warden-1.2.7/lib/warden/manager.rb:35:in call’
2017-05-20T10:52:18.286778+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/etag.rb:25:in call' 2017-05-20T10:52:18.286779+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/conditional_get.rb:38:in call’
2017-05-20T10:52:18.286781+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/callbacks.rb:38:in block in call' 2017-05-20T10:52:18.286782+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:97:in run_callbacks
2017-05-20T10:52:18.286780+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/head.rb:12:in call' 2017-05-20T10:52:18.286783+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:750:in _run_call_callbacks’
2017-05-20T10:52:18.286783+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/callbacks.rb:90:in run_callbacks' 2017-05-20T10:52:18.286784+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/callbacks.rb:36:in call’
2017-05-20T10:52:18.286785+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/debug_exceptions.rb:49:in call' 2017-05-20T10:52:18.286785+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/remote_ip.rb:79:in call’
2017-05-20T10:52:18.286786+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/show_exceptions.rb:31:in call' 2017-05-20T10:52:18.286787+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/railties-5.0.3/lib/rails/rack/logger.rb:36:in call_app’
2017-05-20T10:52:18.286787+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/railties-5.0.3/lib/rails/rack/logger.rb:24:in block in call' 2017-05-20T10:52:18.286788+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/tagged_logging.rb:69:in block in tagged’
2017-05-20T10:52:18.286789+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/tagged_logging.rb:26:in tagged' 2017-05-20T10:52:18.286789+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/tagged_logging.rb:69:in tagged’
2017-05-20T10:52:18.286790+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/railties-5.0.3/lib/rails/rack/logger.rb:24:in call' 2017-05-20T10:52:18.286791+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/request_id.rb:24:in call’
2017-05-20T10:52:18.286792+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.3/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' 2017-05-20T10:52:18.286791+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/runtime.rb:22:in call’
2017-05-20T10:52:18.286792+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/executor.rb:12:in call' 2017-05-20T10:52:18.286795+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/static.rb:136:in call’
2017-05-20T10:52:18.286796+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/sendfile.rb:111:in call' 2017-05-20T10:52:18.286796+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/railties-5.0.3/lib/rails/engine.rb:522:in call’
2017-05-20T10:52:18.286797+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/puma-3.8.2/lib/puma/configuration.rb:224:in call' 2017-05-20T10:52:18.286798+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/puma-3.8.2/lib/puma/server.rb:600:in handle_request’
2017-05-20T10:52:18.286798+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/puma-3.8.2/lib/puma/server.rb:435:in process_client' 2017-05-20T10:52:18.286799+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/puma-3.8.2/lib/puma/server.rb:299:in block in run’
2017-05-20T10:52:18.286799+00:00 app[web.1]: [fb643a56-f5b3-4b63-a1a6-4ce56c317f70] vendor/bundle/ruby/2.3.0/gems/puma-3.8.2/lib/puma/thread_pool.rb:120:in `block in spawn_thread’
2017-05-20T10:52:18.288496+00:00 heroku[router]: at=info method=POST path="/auth/sign_in" host=thawing-mesa-14670.herokuapp.com request_id=fb643a56-f5b3-4b63-a1a6-4ce56c317f70 fwd=“159.205.203.189” dyno=web.1 connect=1ms service=165ms status=500 bytes=189 protocol=https
2017-05-20T10:52:33.466720+00:00 heroku[run.5291]: Process exited with status 0
2017-05-20T10:52:33.479624+00:00 heroku[run.5291]: State changed from up to complete

``

I’m not sure why “IndexError: string not matched” occurs.

Generally speaking I want to immplement an Angular 4 app on Rails backend. Can you recommend me other way of implemeting token authentication in Rails?

If devise_token_auth is not working, I need some alternatives.

I was also considering a JWT format for this purposes. What kind of gems should I use then?

Which way is better?

For auth API with manager screen too.
Im using devise with JWT gem

gem 'devise'
gem 'cancancan'
gem 'grape'

gem ‘rack-cors’

gem ‘jwt’

After authen user success. Using JWT to generate authtoken using on each API call