Files
postter/app/controllers/user_follows_controller.rb
João Victor Geonizeli e465123190 implement current_user
2022-02-28 09:48:51 -03:00

30 lines
671 B
Ruby

class UserFollowsController < ApplicationController
# POST /user_follows
# POST /user_follows.json
def create
@user_follow = UserFollow.new(user_follow_params)
if @user_follow.save
render :show, status: :created, location: @user_follow
else
render json: @user_follow.errors, status: :unprocessable_entity
end
end
# DELETE /user_follows/1
# DELETE /user_follows/1.json
def destroy
UserFollow.find(params[:id]).destroy
end
private
# Only allow a list of trusted parameters through.
def user_follow_params
{
follower: current_user,
**params.require(:user_follow).permit(:followed_id)
}
end
end