Rails 3.2
Devise
Devise security extensions
在我的app / views / users / shared / _links.slim中,我有:
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
li.home-nav= link_to t('users.shared.didnt_received_unlock'), new_unlock_path(resource_name)
在我的用户模型中,我有:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :invitable, :confirmable,
:password_expirable, :password_archivable, :session_limitable, :expirable, :secure_validatable,
:lockable, :timeoutable
当用户尝试登录时,出现以下错误:
NameError(未定义的局部变量或方法resource_class' for #<#<Class:0x000000098a1598>:0x000000092d4b60>):
app/views/users/shared/_links.slim:5:in
_ app_views_users_shared__links_slim___1531266065579142927_70700660'
app / views / layouts / application.html.slim:96:在_app_views_layouts_application_html_slim___452855375923455357_79638440'
app/middleware/catch_json_parse_errors.rb:8:in
通话中
有什么想法吗?
答案 0 :(得分:2)
resource_class
仅在Devise控制器中可用,而在_links.slim
视图中不可用。请改用User.unlock_strategy_enabled?(:email)