lib/mongoid_followable/follower.rb
def follow(*models)
      models.each do |model|
        unless model == self or self.follower_of?(model) or model.followee_of?(self) or self.cannot_follow.include?(model.class.name) or model.cannot_followed.include?(self.class.name)
          model.followers.create!(:f_type => self.class.name, :f_id => self.id.to_s)
          model.followed_history << self.class.name + '_' + self.id.to_s
          model.save
          self.followees.create!(:f_type => model.class.name, :f_id => model.id.to_s)
          self.follow_history << model.class.name + '_' + model.id.to_s
          self.save
        end
      end
    end
def follow(*models)
      models.each do |model|
        unless model == self or self.follower_of?(model) or model.followee_of?(self) or self.cannot_follow.include?(model.class.name) or model.cannot_followed.include?(self.class.name)
          model.followers.create!(:f_type => self.class.name, :f_id => self.id.to_s)
          model.followed_history << self.class.name + '_' + self.id.to_s
          model.save
          self.followees.create!(:f_type => model.class.name, :f_id => model.id.to_s)
          self.follow_history << model.class.name + '_' + model.id.to_s
          self.save
        end
      end
    end
def follow ( * models ) models . each do | model | unless model == self or self . follower_of? ( model ) or model . followee_of? ( self ) or self . cannot_follow . include? ( model . class . name ) or model . cannot_followed . include? ( self . class . name ) model . followers . create! ( :f_type => self . class . name , :f_id => self . id . to_s ) model . followed_history << self . class . name + '_' + self . id . to_s model . save self . followees . create! ( :f_type => model . class . name , :f_id => model . id . to_s ) self . follow_history << model . class . name + '_' + model . id . to_s self . save end end end
follow some model
follow some model