Retrospring/app/controllers/ajax/friend_controller.rb

40 lines
990 B
Ruby
Raw Normal View History

class Ajax::FriendController < AjaxController
2014-11-30 05:45:32 -08:00
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 => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail
@response[:message] = I18n.t('messages.friend.create.fail')
2014-11-30 06:13:37 -08:00
return
end
@response[:status] = :okay
@response[:message] = I18n.t('messages.friend.create.okay')
@response[:success] = true
2014-11-30 05:45:32 -08:00
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 => e
NewRelic::Agent.notice_error(e)
@response[:status] = :fail
@response[:message] = I18n.t('messages.friend.destroy.fail')
2014-11-30 06:13:37 -08:00
return
end
@response[:status] = :okay
@response[:message] = I18n.t('messages.friend.destroy.okay')
@response[:success] = true
2014-11-30 05:45:32 -08:00
end
end