Forum: Ruby on Rails Arranging Models

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Siva J. (Guest)
on 2006-02-14 07:04
(Received via mailing list)
I know we could arrange controllers as modules. Can we also arrange
models
in modules?

--
Rgds,
--Siva J.
http://www.varcasa.com/
My First Rails Project.
Education Through Collabration
Warren N. (Guest)
on 2006-02-14 07:35
(Received via mailing list)
On 13-Feb-06, at 9:03 PM, Siva J. wrote:

> I know we could arrange controllers as modules. Can we also arrange
> models in modules?

No you cannot. I dont see the need why any one would want to do it too.

Have you looked at components?

Best Regards,
Warren N..
GNU (http://www.gnu.org.in)
Siva J. (Guest)
on 2006-02-14 07:39
(Received via mailing list)
The reason I need is it package (make a module) for group of related
modules. Something like a package in java

On 2/14/06, Warren N. <removed_email_address@domain.invalid> wrote:
>
>
--
Rgds,
--Siva J.
http://www.varcasa.com/
My First Rails Project.
Education Through Collabration
Ezra Z. (Guest)
on 2006-02-14 18:03
(Received via mailing list)
On Feb 13, 2006, at 9:34 PM, Warren N. wrote:

>
> Best Regards,
> Warren N..
> GNU (http://www.gnu.org.in)
>


	Actually yes you can do that. There is support built into edge rails
recently to enable using modules as namespaces for your models. Here
is what you have to do if you are running 1.0.0. Add this line in
side the environment.rb file inside the Rails::Initializer.run do |
config| block:


   # Add support to use models in modules for namespaces.
   config.controller_paths << File.join(::RAILS_ROOT, 'app', 'models')


	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.

Cheers-
-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732
This topic is locked and can not be replied to.