Forum: Ruby on Rails Question about "partial controllers" sub-applicaktions

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.
556fa76457d930880bea41a80a848867?d=identicon&s=25 Martin No (html-kurs)
on 2008-12-23 20:48
(Received via mailing list)
Hello,

I've got two questions about best practices using Ruby on Rails:

First, think about a website which has several relative independant
parts: Some news, some dates of fairs, some jobs and so on.
Using the "RoR-filesystem layout" there's one folder app/models with all
the models used in these different parts. Another folder app/controllers
containing the different controllers and so on.
Now think about another website on another server which should consist
of similar parts but not of all of them.
So if I want to reuse some parts I have to sort out the parts I need.
That could be tricky. So is there a way to use subfolders in the
following way:
appnews/controllers
        /models
        /views
appdates/controllers
         /models
         /views
appjobs/controllers
        /models
        /views
and so on?
What's "the rails way" to do it?

My second question is about "partial controllers": Think of the above
website. I want to use a (rails-) layout to present all parts in the
same way. Maybe to columns. The main column should contain the main
content of the sub-application (e.g. the latest news). And the second
column should contain content of the other parts (e.g. the latest date
of fairs). Fetching the stuff out of the database (using the different
models) would be part of all controllers. So I'd like to use
"partial-controllers" in a way we use partial views. So I have only to
write the code once and include it from each controller.
So what's the best way to do it in rails?

Thanks,
Martin
Ed437e52d8d6720308720e7e678f3e6d?d=identicon&s=25 Patrick Doyle (Guest)
on 2008-12-23 20:56
(Received via mailing list)
I'll be watching the answers to this thread myself, as I'm curious what
the
experts will reply.  But I (a newbie) suspect one answer may be to write
plugins for those portions of the code that you anticipate will be
reusable.

Of course I haven't the foggiest idea how one starts off writing code in
a
style suitable for being made into a plugin.  But perhaps you and your
friend Google and start investigating that path while you await answers
from
folks who actually do this sort of thing for a living.

--wpd
97f7778bd994b7e4c5ad025be0640bde?d=identicon&s=25 Andrius Chamentauskas (Guest)
on 2008-12-29 13:44
(Received via mailing list)
http://m.onkey.org/2007/12/9/namespaced-models seems to be talking
about same problems. You might wanna read it.
This topic is locked and can not be replied to.