我有一个带有admin子模型的用户模型。
class Admin < User
end
我在用户模型中设计了一个“类型”列。路线看起来像这样:
devise_for :users, :controllers => { :sessions => 'sessions' }, :skip => :registrations
devise_for :admins, :skip => :sessions
我不知道如何覆盖设计,因此我可以使用current_user帮助程序访问管理员。
现在名称未在<%= current_user.name %>
管理员是否也不是用户?我不确定为什么current_user是nil。
在我的sessions_controller中,我有:
class SessionsController < Devise::SessionsController
def create
rtn = super
sign_in(resource.type.underscore, resource.type.constantize.send(:find, resource.id)) unless resource.type.nil?
rtn
end
end