Rails Devise - current_user is nil

后端 未结 4 1201
甜味超标
甜味超标 2021-01-02 00:27

For some reason, current_user returns nil in my model-less controller (Subscriptions). I have found nothing on the Internet to justif

4条回答
  •  执念已碎
    2021-01-02 01:32

    It turned out the AJAX request I was making didn't carry the CSRF token. For that reason, Rails was killing my session.

    I added skip_before_filter :verify_authenticity_token in my SubscriptionsController and it is now working. It might not be the most secure solution, but it works for now, so I continue to develop and come back to this issue later.

提交回复
热议问题