我设置了注册,以便为具有预定密码的用户创建帐户,然后我希望向他们发送一封欢迎电子邮件,其中包含指向设计edit_user_password_url
的链接。
我的方法失败,因为当用户关注链接时,他们会看到以下内容:“如果没有来自密码重置电子邮件,则无法访问此页面。如果您确实来自密码重置电子邮件,请确保使用提供的完整网址。“
如何将欢迎电子邮件包含在密码重置的正确链接中?
# RegistrationsController
def create
if params[:user] && !params[:user][:password]
params[:user][:password] = "testpassword" #obviously not real
build_resource(sign_up_params)
puts sign_up_params
resource.save
yield resource if block_given?
if resource.persisted?
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
NewUserMailer.new_user_email(resource).deliver_now
redirect_to users_path
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}"
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
render :new, :address => params[:address]
end
else
super
end
end
#email
Welcome, follow this link to update your password <%= link_to "My account", edit_user_password_url %></p>