如何检查字符串是否等于另一个字符串?

Edd*_*boh 5 ruby-on-rails

在我的rails应用程序中,我正在尝试检查一个字符串(current_user.email)是否等于另一个字符串(@ user.email).我如何使用if/else语句执行此操作?我试过了

<% if @current_user.email(=@user.bio) %>    
  <a href="google.com"> Link </a>
<% else %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

但是我遇到了语法错误.救命?

Way*_*Lue 9

语法无效(=@.的=是分配,并在方法调用没有用.

你的if线应该是这样的

<% if @current_user.email == @user.email %>
Run Code Online (Sandbox Code Playgroud)