0
class Investor
field :name
has_and_belongs_to_many :users
end
class User
field :name
has_and_belongs_to_many :investors
end
我已經有用戶和投資者,我不希望創建新的。什麼是inclusing像
@user=User.first
@investor=Investor.first
@inves_sec=Investor.last
現在什麼是添加@investor和@invest_sec用戶ID的投資者,可我現在mongoid文檔中發現的命令來創建新的投資對象的方式的方式,我是不是能夠找到你可以使用現有對象的地方。
我不遵循你的問題。 'investor.users.push(@investor)'? – WiredPrairie
感謝它的運作,我在做@ investor.id這就是爲什麼它是一個問題,感謝您的評論。您可以將其發佈爲answer @ user.investors.push(@investor),然後是下一個。我會接受它。 –