Last active
April 27, 2019 02:50
-
-
Save rodloboz/9b962b17206a9535298a0614c8b64665 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users::FollowsController < ApplicationController | |
before_action :set_user | |
def create | |
if current_user.follow(@user.id) | |
respond_to do |format| | |
format.html { redirect_to @user } | |
format.js | |
end | |
end | |
end | |
def destroy | |
if current_user.unfollow(@user.id) | |
respond_to do |format| | |
format.html { redirect_to @user } | |
format.js { render action: :create } | |
end | |
end | |
end | |
private | |
def set_user | |
@user = User.find_by(username: params[:user_username]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment