我有3個模型 - 成員,相冊和圖像。命名空間模型:未初始化的常量成員:: Album :: Image(NameError)
的member.rb文件是在/ app /模型目錄:
class Member < ActiveRecord::Base
has_many :albums
的album.rb文件是在/ app /模型/部件目錄:
class Member::Album < ActiveRecord::Base
has_many :images
圖像.RB文件在/ app /模型/件/專輯目錄:
class Member::Album::Image < ActiveRecord::Base
在我的routes.rb文件,我有:
resources :members do
resources :albums, :controller => 'members/albums' do
resources :images, :controller => 'members/albums/images',:only => [:new, :create, :destroy] do
get :edit, :on => :collection
put :update, :on => :collection
end
end
end
但是,當我嘗試加載'/ members/1/albums'(和其他幾個地方),我得到錯誤未初始化常數Member :: Album :: Image。
我甚至嘗試添加:
config.autoload_paths += %W(#{config.root}/app/models/member/album)
和
config.autoload_paths += Dir["#{config.root}/app/models/**/"]
我的config/application.rb中的文件(並重新啓動服務器),以確保嵌套在子目錄中的我的所有文件內'app/models'文件夾正在加載,但我仍然得到這個錯誤。