2012-11-23 86 views
2

嗨,那里有辉煌的头脑,我试图运行这段代码时遇到了这个问题。无法弄清楚。希望有人能帮忙。未初始化的常量Mail :: Ruby19

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

编辑:我曾尝试重新启动应用程序几次。这不是造成问题的原因。

用户模型:

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 

密码重置控制器:

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: "[email protected]" 

    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 

任何帮助表示赞赏。

非常感谢

+0

'app/mailers/user_mailer.rb'的第一行是什么?从错误消息看来,它似乎是一个'require'语句,无法加载指定的文件。 –

+0

线1级UserMailer <::的ActionMailer基地 2号线从默认:“[email protected]” –

+0

能否请您编辑的问题,包括完整的'应用程序/邮寄/ user_mailer.rb'文件好吗?或者至少在前几行? –

回答

0

总结从意见的答案,以从“未答复”过滤器中删除了这个问题:

Shamir K,则UserMailer语法可能是可疑的。这是一个公平的观测 - 注意由原始的海报在这里使用的原材料:

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

相关问题