Eddy Liaboh
Eddy Liaboh

Reputation: 65

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?

Upvotes: 5

Views: 10445

Answers (2)

uday
uday

Reputation: 8710

<% if @current_user.email == @user.bio %> try this & see.

Upvotes: 2

Waynn Lue
Waynn Lue

Reputation: 11375

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 %>

Upvotes: 9

Related Questions