Phillip Gawlowski wrote:
> On 20.01.2010 02:42, Dan Quach wrote:
>> I'm reading some code and it states..
>>
>>    #this can only occur on the person who was invited
>>      def make_friends(invited, inviter)
>>        transaction do
>>          if user.followed_by? target
>>
>>
>> what does user.followed_by mean?
> 
> The code snippet you provided is far too short to tell you for sure.
> 
> A rough guess would be that #followed_by? checks if the target follows
> the user described in the user object.
> 
> If you could provide more detail, it'd be appreciated. :)

Sorry bout that.. heres the full snippet
    #this can only occur on the person who was invited
    def make_friends(invited, inviter)
      transaction do
        if user.followed_by? target

          #update the existing pending relationship of 2 --> 1
          Friend.find(:first, :conditions => {:inviter_id => inviter.id, 
:invited_id => invited.id, :status => 
PENDING}).update_attribute(:status, ACCEPTED)

          #create the relationship of 1 --> 2
          Friend.create!(:inviter_id => inviter.id, :invited_id => 
invited.id, :status => ACCEPTED)
        else
          return add_follower(user, target)unless user.following? target
        end
      end
      true
    end

-- 
Posted via http://www.ruby-forum.com/.