require 'digest/sha1' class User < ActiveRecord::Base has_many :twits has_many :user_followings, :foreign_key => 'user_id', :class_name => 'UserFollowing', :dependent => :destroy has_many :user_followers, :foreign_key => 'following_user_id', :class_name => 'UserFollowing', :dependent => :destroy has_many :following_users, :through => :user_followings, :source => :following_user has_many :follower_users, :through => :user_followers, :source => :follower_user .........