Ruby 引擎内rails 3.2中的Activerecord抛出NameError:在使用accepts_nested_attributes_时未初始化常量

Ruby 引擎内rails 3.2中的Activerecord抛出NameError:在使用accepts_nested_attributes_时未初始化常量,ruby,activerecord,ruby-on-rails-3.2,rails-engines,Ruby,Activerecord,Ruby On Rails 3.2,Rails Engines,我正在建造一个rails引擎。我有以下两个模型类: module LandingPageEng class LandingPage < ActiveRecord::Base attr_protected # just for debugging right now has_many :slide_show_images, :dependent => :destroy accepts_nested_attributes_for :

我正在建造一个rails引擎。我有以下两个模型类:

module LandingPageEng
    class LandingPage < ActiveRecord::Base
        attr_protected # just for debugging right now
        has_many :slide_show_images, :dependent => :destroy
        accepts_nested_attributes_for :slide_show_images, allow_destroy: true
    end
end
模块着陆页面eng
类登录页:销毁
接受\u嵌套的\u属性\u用于:幻灯片\u显示\u图像,允许\u销毁:true
结束
结束
第二类是:

module LandingPageEng
    class SlideShowImage < ActiveRecord::Base
        attr_accessible :image, :landing_page_id
        belongs_to :landing_page 

        validates :image, :presence => true
    end
end
模块着陆页面eng
类SlideShowImagetrue
结束
结束
与它们相关联的表是登录页面、登录页面和登录页面、登录幻灯片、显示图像

当我在控制台中运行以下命令时,会得到错误名称error:uninitialized constant SlideShowImage

1.9.3-p194 :001 > LandingPageEng::LandingPage.new({"title"=>"wd", "tagline"=>"wed",     "slide_show_images"=>{"_destroy"=>""}})
NameError: uninitialized constant SlideShowImage
    from /Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-  3.2.6/lib/active_support/inflector/methods.rb:229:in `block in constantize'
    from /Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `each'
    from /Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `constantize'
    from /Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
<snip>
1.9.3-p194:001>LandingPageEng::LandingPage.new({“title”=>“wd”,“tagline”=>“wed”,“slide\u show\u images”=>{“destroy”=>”})
NameError:未初始化的常量幻灯片图像
from/Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active\u-support/endoctor/methods.rb:229:in“块在constantize中”
from/Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active\u-support/endoctor/methods.rb:228:in'each'
from/Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active\u support/indlector/methods.rb:228:in“constantize”
from/Users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active\u support/core\u ext/string/influctions.rb:54:in'constantize'

我一直在想这个问题,但想不出来。非常感谢您的帮助。

我没有一个带有引擎的Rails 3设置来快速测试这一点,但我认为问题在于您的
有许多
配置;它正在寻找一个名为
SlideShowImage
的类,但您的类名是
LandingPageEng::SlideShowImage

我相信在你的
中添加一个
:class\u name
选项会解决这个问题


谢谢你帮助Ryan。现在我有点奇怪。现在它似乎期望我用:class_name指定的类,而不是找到一个数组
ActiveRecord::AssociationTypeMismatch:LandingPageEng::SlideShowImage(#70200876366100)应为,Get Array(#70200871589540)
传递的参数似乎有问题。它不是将幻灯片放映图像属性作为键传递,而是从表单中传递幻灯片放映图像。同样的代码在发动机外部运行良好。但这是一个进步。谢谢。似乎是多个变量同时改变的问题。不知道我做了什么。现在一切都正常了,你的解决方案是正确的。谢谢