Skip to content

ultrasaurus/twitter_like_example_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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


About

complex associations example using twitter-like example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors