On Jan 28, 2006, at 6:38 PM, John wrote:
> I have models within a module file and access them from my controller
> with Module::Model syntax, but only get unitialized const errors. I
> even
> tried require ''mymodule'', etc, no avail. The Prg
>
> Google has ZERO help on this, and I can''t believe more people
haven''t
> run into this issue. What''s the deal?
>
> Frustrated,
> John
>
> --
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
John-
Here is what you have to do if you are running 1.0.0. Add this line
in side the environment.rb file here:
Rails::Initializer.run do |config|
# Add support to use models in modules for namespaces.
config.controller_paths << File.join(::RAILS_ROOT,
''app'', ''models'')
#.....
end
Its a little weird becuase you use controller_paths but it will let
you use Admin::Page < AR::Base for your models to have them
namespaced inside of modules.
This is the same way that components are able to load their models
and stuff. There has been support recently added to use this by
default on edge rails but im not sure if its been checked into the
repo yet.
Cheers-
-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732