我有一个包含以下内容的设计用户模型,我确实为其运行了迁移。
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :token_authenticatable, :confirmable, :lockable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :role
# attr_accessible :title, :body
ROLES = ['admin', 'network/system admin', 'manager', 'programmer']
def role?(base_role)
ROLES.index(base_role.to_s) <= ROLES.index(role)
end
end
稍后,我将以下两行添加到同一模型中,并为 Ticket、Projects 和 Assignments 运行迁移。
has_many :projects, :through => :assignments
has_many :tickets
以上是否更新了用户与门票和项目的关联?运行迁移后更改模型中的关联是否有任何问题?我想知道它,因为我现在正在开发 Rails 应用程序。
谢谢 :)-