我是新来的铁路。
我有一个注册表单,用户可以在其中创建项目,同时注册。项目应该被创建,并且新用户成为项目的“管理员”。
我有以下型号:
class Project < A::B
has_many :roles
has_many :users, :through => :roles
has_one :admin, :through => :roles, :conditions => "role.name = 'admin'"
has_many :members, :through => :roles, :conditions => "role.name = 'member'"
end
class User < A::B
has_many :roles
has_many :projects, :through => :roles
end
class Role < A::B
belongs_to :projects
belongs_to :users
end
我正在寻找创建封装模型层中的关系设置,并使其易于在视图中为关系中的所有对象创建表单、显示错误等。
希望我很清楚,新手到 rails 。谢谢