0
我使用Facebook-Omniauth gem將人們連接到我的應用程序。我可以看到新用戶何時登錄,它會在我的數據庫中創建一個新的用戶記錄。我的應用程序應該將用戶連接到他們的朋友和他們的活動......但它只是將用戶連接到所有朋友(人)以及數據庫中的所有事件。Facebook-omniauth&associations:如何將朋友與用戶相關
在User.rb:
has_many :people
has_many :people,
:through => :friends
在Person.rb:
has_many :users,
:through => :friends
在Friend.rb:
belongs_to :person
belongs_to :users
通過所有的朋友通過Omniauth我環認證後用戶已經嘗試將其添加爲用戶的朋友,如下所示:
self.people << @new_person
但是ActiveRecord的罵回來了以下內容:
[3] pry(#<User>)> self.people << @new_person
ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :friends in model User
[4] pry(#<User>)> self.friends << @new_person
NoMethodError: undefined method `friends' for #<User:0x007f9b816850f0>
我缺少什麼?