Created
February 17, 2010 10:51
-
-
Save divineforest/306509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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