Files
manyfold/app/controllers/follows_controller.rb
T
2024-08-01 11:39:15 +01:00

25 lines
547 B
Ruby

class FollowsController < ApplicationController
before_action :get_target
def create
authorize Federails::Following
current_user.follow @target
redirect_to @target
end
def destroy
authorize Federails::Following
current_user.unfollow @target
redirect_to @target
end
private
def get_target
followable = params[:followable_class].constantize
followable_param = params[:followable_class].parameterize + "_id"
id = params[followable_param]
@target = policy_scope(followable).find(id)
end
end