Railsは初めてです。
サインアップフォームがあり、ユーザーはサインアップと同時にプロジェクトを作成できます。プロジェクトが作成され、新しいユーザーがプロジェクトの「管理者」になります。
私は次のモデルを持っています:
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
モデルレイヤーでリレーションシップのセットアップをカプセル化して作成し、リレーションシップ内のすべてのオブジェクトについて、フォームの作成、ビューでのエラーの表示などを簡単に行えるようにすることを探しています。
私が明確であることを願っています、レールの初心者です。ありがとう