我想测试一个应用,并且我具有has_many_through关系。我真的无法正常工作,所以这里是我的设置。
Agent:
has_many :memberships
has_many :organizations, through: :memberships
belongs_to :current_organization
Organizations:
has_many :memberships
has_many :agents, through: :memberships
Memberships:
belongs_to :organization
belongs_to :agent
到目前为止,这是我所拥有的,但是不起作用:(请注意,我尽量避免引用ID)
agents.yml
PistolPete:
current_organization: one
email: pistol@pete.com
encrypted_password: <%= Devise::Encryptor.digest(Agent, '123456789')%>
memberships.yml
membership:
agent: PistolPete
organization: one
role: <%= Membership.roles[:agent] %>
organizations.yml
one:
name: "Pete's shop"
感谢您的帮助或提示!