Ruby on rails 如果数据==条件,如何用占位符覆盖数据?
用户可以通过电子邮件和facebook注册。如果他通过facebook注册,将生成一封随机电子邮件,让他通过验证过程。该电子邮件以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
@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 %>