Hi,
I have a problem with a model which is defined within a namespace. It does not seem to find another namespace that was defined in the environment.
#config/initializers.rb module X class Exception < Exception ...some custom exception definitions here... end end
#app/models/y/my_model.rb class Y::MyModel < ActiveRecord::Base validates_presence_of :attr, :message => X::Exception.new('init).to_string_reference end
This setup fails during boot because the model searches for Y::MyModel::X, which it cannot find: "vendor/rails/activerecord/lib/../../activesupport/lib/active_support/ dependencies.rb:478:in `const_missing':NameError: uninitialized constant Y::MyModel::X"
When I try the following setup:
#app/models/y/my_model.rb class Y::MyModel < ActiveRecord::Base validates_presence_of :attr, :message => ::Exception.new('init).to_string_reference end
It still fails during boot because it still cannot find X: "vendor/rails/activerecord/lib/../../activesupport/lib/active_support/ dependencies.rb:266:in `load_missing_constant':NameError: uninitialized constant X"
However, in my normal models (without a namespace) it does work:
#app/models/my_other_model.rb class MyOtherModel < ActiveRecord::Base validates_presence_of :attr, :message => X::Exception.new('init).to_string_reference end
This loads fine. I don't understand why it does not work in the namespace situation. Does anybody know what I'm doing wrong? I'm using Rails 2.0RC1 by the way.
Thanks in advance, Bas van Westing