Skip to content

Instantly share code, notes, and snippets.

@rodloboz
Created April 27, 2019 00:55
Show Gist options
  • Save rodloboz/d663322b3bd21dc8e406d6cb3d0b8a2d to your computer and use it in GitHub Desktop.
Save rodloboz/d663322b3bd21dc8e406d6cb3d0b8a2d to your computer and use it in GitHub Desktop.
class Follow < ApplicationRecord
belongs_to :follower, class_name: 'User', foreign_key: 'follower_id',
counter_cache: :followings_count,
inverse_of: :following_relationships
belongs_to :following, class_name: 'User', foreign_key: 'following_id',
counter_cache: :followers_count,
inverse_of: :follower_relationships
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment