mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:19:52 +01:00
added ajax controller thing
This commit is contained in:
parent
928addf5db
commit
1b15add6b1
1 changed files with 26 additions and 0 deletions
|
@ -1,11 +1,37 @@
|
|||
class Ajax::FriendController < ApplicationController
|
||||
def create
|
||||
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
|
||||
|
||||
@status = :okay
|
||||
@message = "Successfully followed user."
|
||||
@success = true
|
||||
end
|
||||
|
||||
def destroy
|
||||
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
|
||||
|
||||
@status = :okay
|
||||
@message = "Successfully unfollowed user."
|
||||
@success = true
|
||||
|
|
Loading…
Reference in a new issue