我有一个名为 Person 的模型。我希望用户从人继承。
class Person < ActiveRecord::Base
belongs_to :organization
validates :email, :presence => true, :uniqueness => true
end
class User < Person
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :lockable
# for some reason I HAVE TO user attr_accessor on the following attributes or
# else I would get noMethodError or something like that, I'll fix this later
attr_accessor :username, :encrypted_password, :locked_at, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip, :sign_in_count
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :username, :password, :password_confirmation, :remember_me,
:first_name, :last_name, :mobile_phone, :phone_one, :phone_two, :organization_id
validates :username, :presence => true
end
现在我正在安装 Devise,它想要创建users
带有email
列的表。但我不想要该email
列,因为 User 应该email
从 Person 继承。
我希望 User 模型继承自 People 模型。人们已经有一个email
属性,所以用户不再需要它。
我怎样才能让 Devise 查看表格email
上的列people
而不是可锁定模块的users
表格,以及每当 Devise 需要发送电子邮件时?
我可以email
从迁移中删除该列吗?