Skip to content

Instantly share code, notes, and snippets.

@matsimitsu
Last active August 29, 2015 14:03
Show Gist options
  • Save matsimitsu/ab572e9482f946e8b3f8 to your computer and use it in GitHub Desktop.
Save matsimitsu/ab572e9482f946e8b3f8 to your computer and use it in GitHub Desktop.
def show
@user = User.find_by(username: params[:id])
respond_to do |format|
format.html {
render action: 'show'
}
format.json {
your_friend = false
if user_signed_in?
your_friend = @user.is_friend(current_user) != false
end
user = {
username: @user.username,
your_friend: your_friend,
friend_count: @user.friend_count,
avatar: @user.avatar.url,
bio: @user.bio
}
ActiveSupport::Notifications.instrument('json.render') do
render json: user
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment