Files
libr-2/app/controllers/api/v1/follow_controller.rb
2015-08-12 21:35:24 +08:00

25 lines
629 B
Ruby

class Api::V1::FollowController < Api::V1::ApplicationController
before_action :load_target_user
def create
if @current_user.stars.include? @target_user
render json: {msg: '请不要重复关注'}, status: 400
else
@current_user.follow_relations.create star_id: @target_user.id
render json: {msg: 'done'}
end
end
def destroy
if @current_user.stars.include? @target_user
@current_user.follow_relations.find_by(star_id: @target_user.id).destroy!
render json: {msg: 'done'}
else
render json: {msg: '非粉丝不能进行该操作'}, status: 400
end
end
end