Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如果数据==条件,如何用占位符覆盖数据?_Ruby On Rails_Ruby_Email_Conditional - Fatal编程技术网

Ruby on rails 如果数据==条件,如何用占位符覆盖数据?

Ruby on rails 如果数据==条件,如何用占位符覆盖数据?,ruby-on-rails,ruby,email,conditional,Ruby On Rails,Ruby,Email,Conditional,用户可以通过电子邮件和facebook注册。如果他通过facebook注册,将生成一封随机电子邮件,让他通过验证过程。该电子邮件以@mailinator.com结尾 现在,如果用户希望为其挑战发送电子邮件提醒,那么如果该电子邮件以mailinator.com结尾,我们如何用占位符“Enter email”替换默认电子邮件 挑战控制器 class ChallengesController < ApplicationController before_action :update_use

用户可以通过电子邮件和facebook注册。如果他通过facebook注册,将生成一封随机电子邮件,让他通过验证过程。该电子邮件以
@mailinator.com
结尾

现在,如果用户希望为其挑战发送电子邮件提醒,那么如果该电子邮件以
mailinator.com
结尾,我们如何用占位符“Enter email”替换默认电子邮件

挑战控制器

class ChallengesController < ApplicationController
  before_action :update_user_email, if: proc {|c| c.current_user.present? && c.params[:email].present? }

  def update_user_email
    email = params[:email]
    current_user.update_attribute(:email, email)
  end
end

我想你想要这样的东西

<% if current_user.email.end_with? "@mailinator.com" %>
  <%= email_field_tag :email,  nil, placeholder: 'Enter email...' %>
<% else %>
    Send email to <%= text_field_tag :email, current_user.email %>
<% end %>

发送电子邮件至
不是“像这样的东西”。就是这样。谢谢:]
def self.from_omniauth(auth)
  user.email = SecureRandom.hex + "@mailinator.com"
  user.save!
end
<% if current_user.email.end_with? "@mailinator.com" %>
  <%= email_field_tag :email,  nil, placeholder: 'Enter email...' %>
<% else %>
    Send email to <%= text_field_tag :email, current_user.email %>
<% end %>