Last active
August 29, 2015 14:03
-
-
Save matsimitsu/ab572e9482f946e8b3f8 to your computer and use it in GitHub Desktop.
This file contains 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
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