Basic Challenge: Sign-in Status

Fix a logical issue in your application by solving this challenge.

We'll cover the following

Problem statement

In the previous lesson, you may have come across an error in the line for index.html.erb:

<% if current_user.liked? link %>

This error occurs in case no user is signed-in. The current_user call will return nil, so you cannot make a valid call to .liked?.

Run the application, sign-in, and create a new link. Once the link is created sign-out, you will receive an error.

Your challenge is to fix the error by checking whether a user is signed-in or not.

In case no user is signed-in, the like button will not be displayed.


Implementation

Get hands-on with 1200+ tech skills courses.