Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Model schemas and relationships for "follower" and "followed" users
# == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# title :string(255)
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Event < ActiveRecord::Base
belongs_to :user
end
# == Schema Information
#
# Table name: follow_up_relationships
#
# id :integer not null, primary key
# follower_id :integer
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class FollowUpRelationship < ActiveRecord::Base
belongs_to :user
belongs_to :follower, :class_name => "User"
end
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255) not null
# created_at :datetime not null
# updated_at :datetime not null
#
class User < ActiveRecord::Base
attr_accessible :name
validates_presence_of :name
has_many :follower_relationships, :class_name => "FollowUpRelationship"
has_many :followers, :through => :follower_relationships
has_many :followed_relationships, :class_name => "FollowUpRelationship", :foreign_key => :follower_id
has_many :followeds, :through => :followed_relationships, :source => :user
has_many :events
def followed_events
Event.where(:user_id => followeds)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.