ultrasaurus/twitter_like_example_app
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
An example app with some complex associations for experimenting with Arel
people table joins on itself via followings...
class Person < ActiveRecord::Base
belongs_to :language
has_many :tweets
has_many :follows, :foreign_key => :followed_person_id, :class_name => "Following"
has_many :followed_people, :through => :followings
has_many :followings, :foreign_key => :follower_id
has_many :followers, :through => :followings
end
class Following < ActiveRecord::Base
belongs_to :followed_person, :class_name => 'Person'
belongs_to :follower, :class_name => 'Person'
end
People also have tweets (which should have some text, but I forgot that)
class Tweet < ActiveRecord::Base
belongs_to :person
belongs_to :language
end
Both Tweets and People belong to a language:
class Language < ActiveRecord::Base
has_many :people
has_many :tweets
end