0

对于以下问题,您会推荐哪种方法:我的应用程序需要一个帐户,多个用户在同一个帐户上输入任务。只有其中一位用户(打开帐户的用户)将拥有管理员权限。

我正在考虑使用 Authlogic 进行身份验证,使用 CanCan 来确定用户权限。关键是我希望打开帐户的用户默认是管理员,他是唯一能够为他的帐户生成具有不同权限的其他用户的用户。

4

1 回答 1

1

为什么不将您的用户模型分为帐户和个人资料?“帐户”将有每个用户的用户名和密码,“个人资料”将保留一个列表(通过联合表或 :through 表)以跟踪管理员和编辑?

class Account < ActiveRecord::Base
  has_many :roles
  has_many :profiles, :through => :roles
end


class Profile < ActiveRecord::Base
  has_many :roles
  has_many :accounts, :through => :roles
end

class Role < ActiveRecord::Base
  belongs_to :account
  belongs_to :profile
  attr_accessible :is_admin, :account_id, :profile_id
end
于 2010-06-03T22:18:12.267 回答