mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 19:52:18 -05:00
25 lines
547 B
Ruby
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
|