thirteen-tien-len/app/controllers/relationships_controller.rb
2023-11-21 17:19:33 +00:00

17 lines
431 B
Ruby

class RelationshipsController < ApplicationController
def create
authorize Relationship
leader = params[:followable_type].constantize.find(params[:followable_id])
current_user.follow(leader)
redirect_to leader
end
def destroy
relationship = Relationship.find(params[:id])
authorize relationship
leader = relationship.followable
current_user.unfollow(leader)
redirect_to leader
end
end