Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check if a string is equal to another string?

In my rails app, I'm trying to check if one string (current_user.email) is equal to another string, (@user.email). How would I do this with an if/else statement? I tried

<% if @current_user.email([email protected]) %>    
  <a href="google.com"> Link </a>
<% else %>
<% end %>

but I got a syntax error. help?

like image 801
Eddy Liaboh Avatar asked Mar 10 '12 01:03

Eddy Liaboh


1 Answers

The invalid syntax is (=@. The = is for assignment and has no use in method invocation.

Your if line should look like

<% if @current_user.email == @user.email %>
like image 144
Waynn Lue Avatar answered Sep 28 '22 00:09

Waynn Lue