You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm testing an API using devise_token_auth using Postman. Sign in works with no problem and returns the expected body and headers. I store the headers (I've manually verified that the correct header values are stored) and provide them in a subsequent call to create an object. In this case, it's a task. My controller builds on the current_user which should be available via devise_token_auth as I've provided the headers with the call. However, I get this error
NoMethodError (undefined method tasks' for nil:NilClass)`
which is triggered on this line
@task = current_user.tasks.create!(task_params)
What am I doing wrong? Or is this a bug?
The text was updated successfully, but these errors were encountered:
@jraczak If you mounted the gem at 'api' or even 'api/v1' namespace then the methods change:
current_user becomes current_api_user or even current_api_v1_user
I'm testing an API using
devise_token_auth
using Postman. Sign in works with no problem and returns the expected body and headers. I store the headers (I've manually verified that the correct header values are stored) and provide them in a subsequent call to create an object. In this case, it's atask
. My controller builds on thecurrent_user
which should be available via devise_token_auth as I've provided the headers with the call. However, I get this errorNoMethodError (undefined method
tasks' for nil:NilClass)`which is triggered on this line
@task = current_user.tasks.create!(task_params)
What am I doing wrong? Or is this a bug?
The text was updated successfully, but these errors were encountered: