gpt4 book ai didi

ruby-on-rails - 未初始化的常量 Mail::Ruby19

转载 作者:太空宇宙 更新时间:2023-11-03 16:54:19 24 4
gpt4 key购买 nike

嗨,聪明的头脑,我在尝试运行这段代码时遇到了这个问题。想不通。希望有人能帮忙。

这是“忘记密码”重置邮件。

编辑:我试过几次重启应用程序。这不是导致问题的原因。

用户模型:

validations up here...

def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end

def send_password_reset
generate_token(:password_reset_token)
self.password_reset_sent_at = Time.zone.now
save!
UserMailer.deliver_password_reset(self)
end

密码重置 Controller :

def create
user = User.find_by_email(params[:email])
user.send_password_reset if user
redirect_to signin_path, :notice => "Email sent with instructions."
end

用户邮件:

class UserMailer < ActionMailer::Base
default from: "noreply@mysite.com"

def password_reset(user)
@user = user
mail(:to => user.email, :subject => "Eventalist - Password Reset.")
end
end

错误:

uninitialized constant Mail::Ruby19

app/mailers/user_mailer.rb:1:in `<top (required)>'
app/models/user.rb:19:in `send_password_reset'
app/controllers/password_resets_controller.rb:7:in `create'

This error occurred while loading the following files:
mail

感谢任何帮助。

非常感谢

最佳答案

总结评论中的答案,以便从“未回答”过滤器中删除此问题:

根据 Shamir K , UserMailer 语法可能值得怀疑。这是一个公平的观察——注意原始海报在这里使用的源 Material :

RailsCast #274: Remember Me & Reset Password

也就是说,original poster后来澄清说他的问题是某些缺少配置的结果:

It was a bug. For some reason when i generated the mailer, rails go lazy and forgot to dome some of the configuration that it normally does. It's all good now. thanks

关于ruby-on-rails - 未初始化的常量 Mail::Ruby19,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13532685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com