True or False?
Logan CoBell
Posted on November 5, 2022
In one of our class projects we need to be able to show whether or not a users' account is private or not. To do this I chose to use an if/else statement and used the logical operator && (and) to check if the user whose page we are on is private by writing
if @the_user.private && "false"
<dd>true</dd>
else
<dd>false</dd>
@the_user is an instance variable in this ruby code that returns the user whose page we are currently on, private is one of the columns in our Users table from our database that stores the boolean value that we compare with "false" thus getting the correct return value.
💖 💪 🙅 🚩
Logan CoBell
Posted on November 5, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.