Rails Devise - current_user is nil

后端 未结 4 1214
甜味超标
甜味超标 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:06

    I had a similar issue but I was editing the model. So everytime I updated the model suddenly that would happen:

    current_model to nil
    

    After analyzing things, it turns out that if you leave the password in the form, when the user tries to edit some attribute, the person is then forced to write a password.
    Once the form is delivered and updated, Devise does the rational thing when someone updates a password, which is to destroy the session and ask the user to sign in again.

    So that was why current_model was suddenly turning to nil. Hope this helps, have a great day!

提交回复
热议问题