Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save nickstamas/2605559 to your computer and use it in GitHub Desktop.

Select an option

Save nickstamas/2605559 to your computer and use it in GitHub Desktop.
class RelationshipsController < ApplicationController
before_filter :authenticate
def create
@user = User.find(params[:relationship][:followed_id])
current_user.follow!(@user)
respond_to do |format|
format.html { redirect_to @user }
format.js
end
end
def destroy
@user = Relationship.find(params[:id]).followed
current_user.unfollow!(@user)
respond_to do |format|
format.html { redirect_to @user }
format.js
end
end
def index
results = current_user.reciprocal_followers_by_name(params[:query])
respond_to do |format|
format.js { render :json => results }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment