我想找到的followed_users
我想找到我在我的樣本Twitter上所有的追隨者的鳴叫Rails應用程序
用戶模式
class User < ActiveRecord::Base
has_many :tweets, dependent: :destroy
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
has_many :followed_users, through: :relationships, source: :followed
has_many :reverse_relationships, foreign_key: "followed_id", class_name: "Relationship", dependent: :destroy
has_many :followers, through: :reverse_relationships, source: :follower
分享Tweet模式的鳴叫
class Tweet < ActiveRecord::Base
belongs_to :user
關係模型
class Relationship < ActiveRecord::Base
belongs_to :follower, class_name: "User"
belongs_to :followed, class_name: "User
請幫我看看
- 的鳴叫我所有的
followed_users
- 鳴叫應
:created_at
責令
編輯:
我不想實際Twitter的推文。我想要我的應用程序的推文。
我想知道如何做到這一點,而不是使用API – rejin