Rails 3.2.8 Actionmailer-堆栈级别太深,加上未初始化的常量Mail :: Ruby19 [英] Rails 3.2.8 Actionmailer - stack level too deep PLUS uninitialized constant Mail::Ruby19

查看:72
本文介绍了Rails 3.2.8 Actionmailer-堆栈级别太深,加上未初始化的常量Mail :: Ruby19的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注StackOverflow帖子中引用的有关简单联系表单的教程。教程在此处: http://matharvard.ca/ posts / 2011 / aug / 22 / contact-form-in-rails-3 /

I'm following a tutorial referenced in a StackOverflow post for a simple contact form. Tutorial is here: http://matharvard.ca/posts/2011/aug/22/contact-form-in-rails-3/

一切都是复制/粘贴并更改我的域的一些值和邮件设置。遇到两个非常奇怪的错误:当我第一次提交联系表单时,我得到一个:

Everything is copy/paste and change a few values for my domain and mail settings. Running into two very strange errors: When I first submit the contact form, I get a :


堆栈级别太深

stack level too deep

Rails.root:/ Users / me / application

Rails.root: /Users/me/application

应用程序跟踪|框架跟踪完全跟踪

Application Trace | Framework Trace | Full Trace

加载以下文件时发生此错误:

This error occurred while loading the following files:

mail

mail / parsers / rfc2822_obsolete

mail/parsers/rfc2822_obsolete

如果我重新提交而不重新启动Rails应用程序,则会得到:

If I resubmit without restarting the rails app, I get:


未初始化的常量Mail :: Ruby19

uninitialized constant Mail::Ruby19

Rails.root:/ Users / me / application

Rails.root: /Users/me/application

应用程序跟踪|框架跟踪完整跟踪

Application Trace | Framework Trace | Full Trace

app / mailers / notifications_mailer.rb:1:in`'

app/mailers/notifications_mailer.rb:1:in `'

app / controllers / contact_controller .rb:11:in'create'

app/controllers/contact_controller.rb:11:in `create'

此错误在加载以下文件时发生:

This error occurred while loading the following files:

mail

我认为可能涉及的部分是:

The sections I feel might be relavent are:

class NotificationsMailer < ActionMailer::Base
  default :from => "feedback@mydomain.com"
  default :to => "me@gmail.com"

  def new_message(message)
    @message = message
    mail(:subject => "mydomain Feedback")
  end
end

class Message
  include ActiveModel::Validations
  include ActiveModel::Conversion
  extend ActiveModel::Naming

  attr_accessor :name, :email, :subject, :body

  validates :name, :email, :subject, :body, :presence => true
  validates :email, :format => { :with => %r{.+@.+\..+} }, :allow_blank => true

  def initialize(attributes = {})
    attributes.each do |name, value|
      send("#{name}=", value)
    end
  end

  def persisted?
    false
  end
end

class ContactController < ApplicationController
  def new
    @message = Message.new
  end

  def create
    @message = Message.new(params[:message])        
    if @message.valid?
        NotificationsMailer.deliver_new_message params[:message]
      # NotificationsMailer.new_message(@message).deliver
      redirect_to(root_path, :notice => "Message was successfully sent.")
    else
      flash.now.alert = "Please fill all fields."
      render :new
    end
  end
end

其余的模板非常简单并且可以很好地呈现。

The rest of the templates are very straightforward and rendering fine.

此外,附加gemfile以防万一我错过了一些明显的冲突:

Also, attaching the gemfile in case I missed some obvious conflict in there:

source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'sqlite3'
gem 'redis', '2.1.1'
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'jade'
gem "haml", ">= 3.1.7"
gem "haml-rails", ">= 0.3.5", :group => :development
gem "hpricot", ">= 0.8.6", :group => :development
gem "ruby_parser", ">= 2.3.1", :group => :development
gem "rspec-rails", ">= 2.11.4", :group => [:development, :test]
gem "email_spec", ">= 1.2.1", :group => :test
gem "cucumber-rails", ">= 1.3.0", :group => :test, :require => false
gem "database_cleaner", ">= 0.9.1", :group => :test
gem "launchy", ">= 2.1.2", :group => :test
gem "capybara", ">= 1.1.2", :group => :test
gem "factory_girl_rails", ">= 4.1.0", :group => [:development, :test]
gem "bootstrap-sass", ">= 2.1.0.1"
gem "devise", ">= 2.1.2"
gem "cancan", ">= 1.6.8"
gem "rolify", ">= 3.2.0"
gem "simple_form", ">= 2.0.4"
gem "quiet_assets", ">= 1.0.1", :group => :development
gem "hub", ">= 1.10.2", :require => nil, :group => [:development]
gem 'paperclip'
gem 'aws-sdk'
gem 'aws-s3'
gem "high_voltage"

谢谢。

推荐答案

I认为ContactController.rb中的以下代码是罪魁祸首:

I think the following code from ContactController.rb is the culprit:

NotificationsMailer.deliver_new_message params[:message]

您实际上没有方法名称deliver_new_message

You do not actually have a method name deliver_new_message

尝试将其删除,并取消注释下面的行:

Try removing it, and uncommenting the line below it:

NotificationsMailer.new_message(@message).deliver

希望这会有所帮助

这篇关于Rails 3.2.8 Actionmailer-堆栈级别太深,加上未初始化的常量Mail :: Ruby19的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆