Kolejny dziwny problem:
model store/product.rb
class Store::Product < ActiveRecord::Base
end
Akcja show_product w kontrolerze Index działa bez problemów:
http://localhost:3000/index/show_product
[code]class IndexController < ApplicationController
def show_product
@product = Store::Product.find :first
end
end[/code]
Natomiast akcja show_product w kontrolerze Admin::Index
http://localhost:3000/admin/index/show_product
[code]class Admin::IndexController < Admin::ApplicationController
def show_product
@product = Store::Product.find :first
end
end
class Admin::ApplicationController < ApplicationController
end[/code]
powoduje wyjątek:
[code] LoadError in Admin/indexController#show_product
Expected ./app/models/store/product.rb to define Product
RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace
/var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:249:in load_missing_constant' /var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:inconst_missing’
/var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:464:in const_missing' /var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:260:inload_missing_constant’
/var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in const_missing' /var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:260:inload_missing_constant’
/var/lib/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in const_missing' /var/www/rails/depot/app/controllers/admin/index_controller.rb:4:inshow_product’[/code]
Aplikacja identycznie zachowuje się dla:
module Store
class Product < ActiveRecord::Base
end
end
Po kilku próbach odkryłem, że dodanie klasy Product w store/product.rb:
[code]class Store::Product < ActiveRecord::Base
end
class Product < Store::Product
end[/code]
naprawia ten problem.
Intuicja podpowiada mi, że nie jest to zbyt dobre rozwiązanie 
W environment.rb ładuję modele ze wszystkich podkatalogów:
config.load_paths += Dir[RAILS_ROOT + '/app/models/*/']
Czy zachowanie to jest z winy ROR-a 1.2.6, czy jest to po prostu moje niedouczenie?