app/helpers/muck_friends_helper.rb
def friend_link(user, target)
    
    # User not logged in
    if user.blank?
      if MuckFriends.configuration.enable_following
        key = 'login_or_sign_up_to_follow'
      elsif MuckFriends.configuration.enable_friending
        key = 'login_or_sign_up_to_friend'
      else
        return ''
      end
      return wrap_friend_link(I18n.t("muck.friends.#{key}", :login => link_to(t('muck.friends.login'), login_path), :signup => link_to(t('muck.friends.signup'), signup_path)))
    end
    
    return '' if target.blank?
    return '' if user == target
    
    dom_id = make_id(user, target)
        
    if MuckFriends.configuration.enable_friending
      if user.friend_of?(target)
        return wrap_friend_link(link_to( I18n.t('muck.friends.stop_being_friends_with', :user => target.display_name), user_friend_path(user, target), :class => 'ajax-delete'), dom_id)
      elsif user.following?(target)
        return wrap_friend_link( I18n.t('muck.friends.friend_request_pending', :link => link_to(I18n.t('muck.friends.delete'), user_friend_path(user, target), :class => 'ajax-delete')), dom_id)
      end
    elsif MuckFriends.configuration.enable_following
      if user.following?(target)
        return wrap_friend_link(link_to( I18n.t('muck.friends.stop_following', :user => target.display_name), user_friend_path(user, target), :class => 'ajax-delete'), dom_id)
      end
    end
    
    if MuckFriends.configuration.enable_friending && user.followed_by?(target)
      return wrap_friend_link(link_to( I18n.t('muck.friends.acccept_friend_request', :user => target.display_name), user_friends_path(user, :id => target), :class => 'ajax-update'), dom_id)
    end
    
    if MuckFriends.configuration.enable_following
      wrap_friend_link(link_to( I18n.t('muck.friends.start_following', :user => target.display_name), user_friends_path(user, :id => target), :class => 'ajax-update'), dom_id)
    elsif MuckFriends.configuration.enable_friending
      wrap_friend_link(link_to( I18n.t('muck.friends.friend_request_prompt', :user => target.display_name), user_friends_path(user, :id => target), :class => 'ajax-update'), dom_id)
    end
    
  end
# Render a follow/unfollow/friend request link appropriate to the current application settings and user relationship
# Requires enable_following and enable_friending be set in configuration see README
#   If enable_following is true and enable_friending is false then only follow/unfollow links will be shown
#   If enable_following is false and enable_friending is true then only friend request and unfriend links will be shown
#   If enable_following is true and enable_friending is true then a hybrid model will be used.  Users can follow
#   each other without permission but a mutual follow will result in a friendship.  Defriending a user will result in the
#   other user becoming a follower
Render a follow/unfollow/friend request link appropriate to the current application settings and user relationship
Requires enable_following and enable_friending be set in configuration see README
If enable_following is true and enable_friending is false then only follow/unfollow links will be shown
If enable_following is false and enable_friending is true then only friend request and unfriend links will be shown
If enable_following is true and enable_friending is true then a hybrid model will be used.  Users can follow
each other without permission but a mutual follow will result in a friendship.  Defriending a user will result in the
other user becoming a follower
Render a follow / unfollow / friend request link appropriate to the current application settings and user relationship Requires enable_following and enable_friending be set in configuration see README If enable_following is true and enable_friending is false then only follow / unfollow links will be shown If enable_following is false and enable_friending is true then only friend request and unfriend links will be shown If enable_following is true and enable_friending is true then a hybrid model will be used . Users can follow each other without permission but a mutual follow will result in a friendship . Defriending a user will result in the other user becoming a follower
def friend_link(user, target)
    if user.blank?
      if MuckFriends.configuration.enable_following
        key = 'login_or_sign_up_to_follow'
      elsif MuckFriends.configuration.enable_friending
        key = 'login_or_sign_up_to_friend'
      else
        return ''
      end
      return wrap_friend_link(I18n.t("muck.friends.#{key}", :login => link_to(t('muck.friends.login'), login_path), :signup => link_to(t('muck.friends.signup'), signup_path)))
    end
    return '' if target.blank?
    return '' if user == target
    dom_id = make_id(user, target)
    if MuckFriends.configuration.enable_friending
      if user.friend_of?(target)
        return wrap_friend_link(link_to( I18n.t('muck.friends.stop_being_friends_with', :user => target.display_name), user_friend_path(user, target), :class => 'ajax-delete'), dom_id)
      elsif user.following?(target)
        return wrap_friend_link( I18n.t('muck.friends.friend_request_pending', :link => link_to(I18n.t('muck.friends.delete'), user_friend_path(user, target), :class => 'ajax-delete')), dom_id)
      end
    elsif MuckFriends.configuration.enable_following
      if user.following?(target)
        return wrap_friend_link(link_to( I18n.t('muck.friends.stop_following', :user => target.display_name), user_friend_path(user, target), :class => 'ajax-delete'), dom_id)
      end
    end
    if MuckFriends.configuration.enable_friending && user.followed_by?(target)
      return wrap_friend_link(link_to( I18n.t('muck.friends.acccept_friend_request', :user => target.display_name), user_friends_path(user, :id => target), :class => 'ajax-update'), dom_id)
    end
    if MuckFriends.configuration.enable_following
      wrap_friend_link(link_to( I18n.t('muck.friends.start_following', :user => target.display_name), user_friends_path(user, :id => target), :class => 'ajax-update'), dom_id)
    elsif MuckFriends.configuration.enable_friending
      wrap_friend_link(link_to( I18n.t('muck.friends.friend_request_prompt', :user => target.display_name), user_friends_path(user, :id => target), :class => 'ajax-update'), dom_id)
    end
  end
def friend_link ( user , target ) if user . blank? if MuckFriends . configuration . enable_following key = 'login_or_sign_up_to_follow' elsif MuckFriends . configuration . enable_friending key = 'login_or_sign_up_to_friend' else return '' end return wrap_friend_link ( I18n . t ( "muck.friends.#{key}" , :login => link_to ( t ( 'muck.friends.login' ) , login_path ) , :signup => link_to ( t ( 'muck.friends.signup' ) , signup_path ) ) ) end return '' if target . blank? return '' if user == target dom_id = make_id ( user , target ) if MuckFriends . configuration . enable_friending if user . friend_of? ( target ) return wrap_friend_link ( link_to ( I18n . t ( 'muck.friends.stop_being_friends_with' , :user => target . display_name ) , user_friend_path ( user , target ) , :class => 'ajax-delete' ) , dom_id ) elsif user . following? ( target ) return wrap_friend_link ( I18n . t ( 'muck.friends.friend_request_pending' , :link => link_to ( I18n . t ( 'muck.friends.delete' ) , user_friend_path ( user , target ) , :class => 'ajax-delete' ) ) , dom_id ) end elsif MuckFriends . configuration . enable_following if user . following? ( target ) return wrap_friend_link ( link_to ( I18n . t ( 'muck.friends.stop_following' , :user => target . display_name ) , user_friend_path ( user , target ) , :class => 'ajax-delete' ) , dom_id ) end end if MuckFriends . configuration . enable_friending && user . followed_by? ( target ) return wrap_friend_link ( link_to ( I18n . t ( 'muck.friends.acccept_friend_request' , :user => target . display_name ) , user_friends_path ( user , :id => target ) , :class => 'ajax-update' ) , dom_id ) end if MuckFriends . configuration . enable_following wrap_friend_link ( link_to ( I18n . t ( 'muck.friends.start_following' , :user => target . display_name ) , user_friends_path ( user , :id => target ) , :class => 'ajax-update' ) , dom_id ) elsif MuckFriends . configuration . enable_friending wrap_friend_link ( link_to ( I18n . t ( 'muck.friends.friend_request_prompt' , :user => target . display_name ) , user_friends_path ( user , :id => target ) , :class => 'ajax-update' ) , dom_id ) end end
Render a follow/unfollow/friend request link appropriate to the current application settings and user relationship
Requires enable_following and enable_friending be set in configuration see README
If enable_following is true and enable_friending is false then only follow/unfollow links will be shown
If enable_following is false and enable_friending is true then only friend request and unfriend links will be shown
If enable_following is true and enable_friending is true then a hybrid model will be used.
Render a follow / unfollow / friend request link appropriate to the current application settings and user relationship Requires enable_following and enable_friending be set in configuration see README If enable_following is true and enable_friending is false then only follow / unfollow links will be shown If enable_following is false and enable_friending is true then only friend request and unfriend links will be shown If enable_following is true and enable_friending is true then a hybrid model will be used .
# User not logged in
user
target