Skip to content

Instantly share code, notes, and snippets.

@rodloboz
Last active April 27, 2019 02:50
Show Gist options
  • Save rodloboz/9b962b17206a9535298a0614c8b64665 to your computer and use it in GitHub Desktop.
Save rodloboz/9b962b17206a9535298a0614c8b64665 to your computer and use it in GitHub Desktop.
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