Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用单表继承(STI)设计_Ruby On Rails_Devise - Fatal编程技术网

Ruby on rails 使用单表继承(STI)设计

Ruby on rails 使用单表继承(STI)设计,ruby-on-rails,devise,Ruby On Rails,Devise,我在Mongoid和Rails4上工作 我有这样的模型结构(STI) Class User devise :database_authenticatable, :registerable end 用户类具有设计功能 class Teacher < User end class Student < User end 在我定义的学生档案控制器中 before_filter :authenticate_student! 以“学生”身份登录后,如果我单击“学生档案”路径,它将重定向到

我在Mongoid和Rails4上工作 我有这样的模型结构(STI)

Class User
devise :database_authenticatable, :registerable
end
用户类具有设计功能

class Teacher < User
end

class Student < User
end
在我定义的学生档案控制器中

before_filter :authenticate_student!
以“学生”身份登录后,如果我单击“学生档案”路径,它将重定向到根文件。在数据库中,用户类型存储为“type”:“Student”,注册时我通过collectionselect传递_type值


是否有任何设置或代码的东西,我必须做

你有什么课?有监狱长吗_典狱长?您可能需要将其显式存储为
登录:student、user if user
或类似内容that@faron我没有使用任何类型的管理员用户?设计认证很简单。你能详细说明一下吗!!!
before_filter :authenticate_student!