mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-15 08:16:00 +10:00
25 lines
629 B
Ruby
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
|