资源在Devise中是什么意思? [英] What does resource mean in Devise?

查看:72
本文介绍了资源在Devise中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改用户登录时在设计中发生的事情。当我查看源代码时,资源一词无处不在,但我不明白它代表什么。

I want to change what happenes in devise when a user logs in.. When I look at the source code the word resource is everywhere, but I can't understand what it is a stand in for. Does it only pertain to devise and warden?

def after_sign_in_path_for(resource)
  stored_location_for(resource) ||
    if resource.is_a?(User) && resource.can_publish?
      publisher_url
    else
      super
    end
end


推荐答案

资源是用户实例的抽象名称。可以在devise设置中对其进行配置,以与Admin模型或任何其他模型一起使用。

Resource is an abstraction name of instance of a user. It can be configured in devise settings to work with Admin model or any other.

默认情况下,这是您在路线中声明的第一个devise角色

By default it's the first devise role declared in your routes

devise :users  # resource is instance of User class
devise :admins # resource is instance of Admin class

这篇关于资源在Devise中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆