feature/share-libs
rb 19 lines 482 Bytes
Raw
1 class RelationshipsController < ApplicationController
2 before_action :auth_user
3
4 def auth_user
5 redirect_to login_path(redirect_to: request.path) unless user_signed_in?
6 end
7
8 def create
9 user = User.find(params[:followed_id])
10 current_user.follow(user)
11 redirect_to profile_path(user.username_or_id)
12 end
13
14 def destroy
15 user = Relationship.find(params[:id]).followed
16 current_user.unfollow(user)
17 redirect_to profile_path(user.username_or_id)
18 end
19 end