从Rails 5中的演示者访问current_user

问题描述 投票:0回答:1

我已经设计好了滑轨,想在演示者中访问current_user。我一直在使用

ActionController::Base.helpers

访问我的其他助手,但是current_user不可用。如何访问?

谢谢

ruby-on-rails ruby ruby-on-rails-5
1个回答
0
投票

这里是Devise的文档

https://github.com/plataformatec/devise#controller-filters-and-helpers

  1. 您的设计型号名称是'User'吗?
  2. 您是否使用了'before_action:authenticate_user!'行?在控制器中?
  3. 如果是这样,则应具有帮助程序方法current_user(在视图和控制器中可访问)
© www.soinside.com 2019 - 2024. All rights reserved.