1
我有一個users_manager引擎,它有一個User
模型類。修改控制器文件後加載了哪些文件?
在其他購物搜索引擎,我在User
模型添加一些協會與下面的代碼,在shopping/lib/shopping.rb
:
module Shopping
class Engine<Rails::Engine
initializer :shopping_append_user do
UsersManager::User.class_eval do
has_many :products,:class_name=>"Shopping::Product"
has_many :virtues,:class_name=>"Shopping::Virtue"
has_many :containers,:class_name=>"Shopping::Container"
has_many :concerns,:class_name=>"Shopping::Concern"
has_many :remarks,:class_name=>"Shopping::Remark"
has_many :praisings,:class_name=>"Shopping::Praising"
has_one :cart,:class_name=>"Shopping::Cart"
has_one :shop_information,:class_name=>"Shopping::ShopInformation"
has_many :comments,:class_name=>"Shopping::Comment"
has_many :created_orders,:class_name=>"Shopping::Order",:foreign_key=>"creator_id"
has_many :processing_orders,:class_name=>"Shopping::Order",:foreign_key=>"processor_id"
end
end
initializer :shopping_append_file do
Upload::File.class_eval do
has_many :image_uuids,:class_name=>"Shopping::ImageUuid"
end
end
end
def self.table_name_prefix
"shopping_"
end
end
運行rails server
後,應用程序工作正常。然而,修改一個控制器文件後,我瀏覽網頁,它給了我下面的消息:
undefined method `products' for #<UsersManager::User:0x00000003022a58>
如何軌重新加載該文件修改後他們?我怎樣才能讓我的引擎正常工作?
我的Rails的版本是從GitHub 3.2.0.pre,Ruby是1.9.0。
Thanks.In的config.to_prepare塊,自我是ActionDispatch :: Reloader.So self.customize_file和self.customize_user的一個實例不能在confing.to_prepare塊被調用。 – 2011-12-15 10:55:10