ruby - Activerecord in rails 3.2 within an engine throws NameError: uninitialized constant when using accepts_nested_attributes_for -


i building rails engine. have following 2 model classes:

module landingpageeng     class landingpage < activerecord::base         attr_protected # debugging right         has_many :slide_show_images, :dependent => :destroy         accepts_nested_attributes_for :slide_show_images, allow_destroy: true     end end 

the second class is:

module landingpageeng     class slideshowimage < activerecord::base         attr_accessible :image, :landing_page_id         belongs_to :landing_page           validates :image, :presence => true     end end 

the tables associated them landing_page_eng_landing_page , landing_page_eng_slide_show_image.

when run following in console error nameerror: uninitialized constant slideshowimage.

1.9.3-p194 :001 > landingpageeng::landingpage.new({"title"=>"wd", "tagline"=>"wed",     "slide_show_images"=>{"_destroy"=>""}}) nameerror: uninitialized constant slideshowimage     /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'     /users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `each'     /users/martinjlogan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb:228:in `constantize'     /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> 

i have been banging head on , can't figure out. appreciated.

i don't have rails 3 setup engines test on think issue has_many configuration; it's looking class that's named slideshowimage class name landingpageeng::slideshowimage.

i believe adding :class_name option has_many fix this.

http://railsapi.com/doc/rails-v3.0.8rc1/classes/activerecord/associations/classmethods.html#m004956


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -