DEV Community

Logan CoBell
Logan CoBell

Posted on

True or False?

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>
Enter fullscreen mode Exit fullscreen mode

@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.

Top comments (1)

Collapse
 
integerman profile image
Matt Eland

Hi Logan. You may want to put the #ruby tag on this post so people in the Ruby community can find it.

Also, can you clarify this post: are you asking a question about Ruby or sharing something you can do with Ruby?