Skip to content

Instantly share code, notes, and snippets.

@divineforest
Created February 17, 2010 10:51
Show Gist options
  • Save divineforest/306509 to your computer and use it in GitHub Desktop.
Save divineforest/306509 to your computer and use it in GitHub Desktop.
class FriendsController < ApplicationController
def create
@friend = find_friend
current_user.request_friend(@friend)
render :text => "Заявка отправлена"
end
def requests
@friends_requested = current_user.friends_requested
end
def index
@friends = current_user.friends
end
def accept
@friend = find_friend
current_user.accept_friend_request(@friend)
render :text => "Добавлен в друзья"
end
def decline
@friend = find_friend
current_user.decline_friend_request(@friend)
render :text => "Заявка отклонена"
end
def destroy
@friend = find_friend
current_user.destroy_friend(@friend)
render :text => "Убран из списка друзей"
end
private
def find_friend
User.find(params[:id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment