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.
33bb150cf13d87bce4e80569ca317647?d=identicon&s=25 Siva Jagadeesan (Guest)
on 2006-02-14 06:04
(Received via mailing list)
I know we could arrange controllers as modules. Can we also arrange
models
in modules?

--
Rgds,
--Siva Jagadeesan
http://www.varcasa.com/
My First Rails Project.
Education Through Collabration
711eb56e970b483e2c9d929bd036a89e?d=identicon&s=25 Warren Noronha (Guest)
on 2006-02-14 06:35
(Received via mailing list)
On 13-Feb-06, at 9:03 PM, Siva Jagadeesan 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 Noronha.
GNU (http://www.gnu.org.in)
33bb150cf13d87bce4e80569ca317647?d=identicon&s=25 Siva Jagadeesan (Guest)
on 2006-02-14 06: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 Noronha <warren@gnu.org.in> wrote:
>
>
--
Rgds,
--Siva Jagadeesan
http://www.varcasa.com/
My First Rails Project.
Education Through Collabration
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-14 17:03
(Received via mailing list)
On Feb 13, 2006, at 9:34 PM, Warren Noronha wrote:

>
> Best Regards,
> Warren Noronha.
> 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 Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
This topic is locked and can not be replied to.