简体   繁体   中英

Rails: Devise - user_signed_in not recognized

I am using Devise with a Registration model/controller/views (to do new registration) and a User model to do Edit/Update/Show.

Everything seems to be working fine (registration, confirmation, etc.). I am having a problem when I try to use the user_signed method in my application. I am getting the following error message:

undefined local variable or method `user_signed_in'

I researched this issue on StackOverflow, and applying what I learned from several Q&A sessions, here's what I did:

In my User model (user.rb), I have the following:

devise :database_authenticatable

In my User controller, I added the following:

before_filter :authenticate_user!

But I'm still getting the error. I also tried adding the before_filter to the Registration controller and the Application controller, but I'm still getting the error message.

Any ideas?

Work Around

I am using some_action if current_user?

as a workaround, but I am still interested in figuring out if anyone has an answer to the original question.

尝试添加问号

user_signed_in?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM