Skip to content

Instantly share code, notes, and snippets.

@eagsalazar
Created August 14, 2011 18:11
Show Gist options
  • Save eagsalazar/1145145 to your computer and use it in GitHub Desktop.
Save eagsalazar/1145145 to your computer and use it in GitHub Desktop.
class User
has_and_belongs_to_many :followers, :class_name => "User", :inverse_of => :followings
has_and_belongs_to_many :followings, :class_name => "User", :inverse_of => :followers
has_and_belongs_to_many :club_followings, :class_name => "Club", :inverse_of => :followers
end
class Club
has_and_belongs_to_many :followers, :class_name => "User", :inverse_of => :club_followings
end
# OR if polymorphic worked with habtm
class User
has_and_belongs_to_many :followers, :polymorphic => true, :inverse_of => :followings
has_and_belongs_to_many :followings, :polymorphic => true, :inverse_of => :followers
end
class Club
has_and_belongs_to_many :followers, :polymorphic => true, :inverse_of => :followings
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment