Forum: Ruby on Rails Naming controllers in modules?

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.
kristersaurus (Guest)
on 2007-05-30 13:21
(Received via mailing list)
Hey guys.

I noticed in an example from the active scaffold documentation that it
seems to be possible to put rails controllers in modules, a la "class
Admin::CompaniesController < ApplicationController". Does anyone know
anything about this? What do you name the file? Do you put it in a
subdirectory?

Thanks.
Jean-Etienne D. (Guest)
on 2007-05-30 15:54
Hi,

Just: script/generate model controlelr admin::companies
And that is was!

It will create a controller named CompanyController in a subdir named
admin. From the ruby point of view, CompanyController belongs to admin
namespace (class Admin::CompanyController)

Regards,
Jean-Etienne
http://www.woa.hu
kristersaurus (Guest)
on 2007-05-31 05:14
(Received via mailing list)
thanks, thats very helpful. one more question: what address does this
get mapped to? ../admin/companies doesn't seem to work...?

On May 30, 6:54 am, Jean-Etienne D. <rails-mailing-l...@andreas-
Mauricio S. (Guest)
on 2007-06-02 09:39
(Received via mailing list)
Funny, I just started using this and wanted to understand exactly that.

I can't test it in my app right now, but I'd venture a guess that it
would map to: admin/company/

Here's a question... I notice you're running the model generator as
well. Does that mean I would not be able to "share" a Company model
between two different controller namespaces, say
Admin::CompanyController and Guest::CompanyController?

Best regards,
Mauricio

---
Mauricio L. Sadicoff
removed_email_address@domain.invalid


"Peace of mind isn't at all superficial, really," I expound. "It's
the whole thing. That which produces it is good maintenance; that
which disturbs it is poor maintenance. What we call workability of
the machine is just an objectification of this peace of mind. The
ultimate test is always your own serenity." - Zen and the Art of
Motorcycle Maintenance.
This topic is locked and can not be replied to.