Retrospring/app/controllers/ajax/friend_controller.rb

40 lines
829 B
Ruby
Raw Normal View History

2014-11-30 05:45:32 -08:00
class Ajax::FriendController < ApplicationController
def create
2014-11-30 06:13:37 -08:00
params.require :screen_name
target_user = User.find_by_screen_name(params[:screen_name])
begin
current_user.follow target_user
rescue
@status = :fail
@message = "You are already following that user."
@success = false
return
end
2014-11-30 05:45:32 -08:00
@status = :okay
@message = "Successfully followed user."
@success = true
end
def destroy
2014-11-30 06:13:37 -08:00
params.require :screen_name
target_user = User.find_by_screen_name(params[:screen_name])
begin
current_user.unfollow target_user
rescue
@status = :fail
@message = "You are not following that user."
@success = false
return
end
2014-11-30 05:45:32 -08:00
@status = :okay
@message = "Successfully unfollowed user."
@success = true
end
end