How much should I pack in a controller (rails)?

I'm new to ruby and rails. I used to code with php and java (WebObjects). Finally I found a language with a framework that nicely abstracts the datamodel with full funtionality on a _sensible_ level and a high level of consistency. Enough of that, we all know ruby is great :wink:

I followed "Agile Web Development with Rails". In the depot application there is one controller "admin" for the backend and another "store" for the public users.
I just started coding my own application with a much more complex model than depot. If I create just one controller for all the backend administration, that one controller may turn out cluttered with far to many methods (like list_customers, list_contacts, list_projects,... instead of just one list). How should organize the code?
Multiple controllers: store_admin, project_admin, billing_admin, ... ?
Or is there some other way I'm not aware of?

thanks
stefan

This is probably a better question for
http://lists.rubyonrails.org/mailman/listinfo

-austin

···

On 10/24/05, Stefan Foulis <newsletters-stefan@foulis.net> wrote:

I'm new to ruby and rails. I used to code with php and java
(WebObjects). Finally I found a language with a framework that nicely
abstracts the datamodel with full funtionality on a _sensible_ level and
a high level of consistency. Enough of that, we all know ruby is great :wink:

I followed "Agile Web Development with Rails". In the depot application
there is one controller "admin" for the backend and another "store" for
the public users.
I just started coding my own application with a much more complex model
than depot. If I create just one controller for all the backend
administration, that one controller may turn out cluttered with far to
many methods (like list_customers, list_contacts, list_projects,...
instead of just one list). How should organize the code?
Multiple controllers: store_admin, project_admin, billing_admin, ... ?
Or is there some other way I'm not aware of?

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Stefan Foulis asked:

I'm new to ruby and rails. ...
I followed "Agile Web Development with Rails"...
How should organize the code?
Multiple controllers: store_admin, project_admin, billing_admin, ... ?
Or is there some other way I'm not aware of?
...

Look up "modules" in the book's index.

Austin's tip on better help than you'll find here is spot on, too - try the
rails list he mentions, and also there's an IRC channel and a reasonably
helpful wiki.

Cheers,
Dave

2005/10/24, Stefan Foulis:

I'm new to ruby and rails. I used to code with php and java
(WebObjects). Finally I found a language with a framework that nicely
abstracts the datamodel with full funtionality on a _sensible_ level and
a high level of consistency. Enough of that, we all know ruby is great :wink:

I followed "Agile Web Development with Rails". In the depot application
there is one controller "admin" for the backend and another "store" for
the public users.
I just started coding my own application with a much more complex model
than depot. If I create just one controller for all the backend
administration, that one controller may turn out cluttered with far to
many methods (like list_customers, list_contacts, list_projects,...
instead of just one list). How should organize the code?
Multiple controllers: store_admin, project_admin, billing_admin, ... ?
Or is there some other way I'm not aware of?

thanks
stefan

Hi,
To resolve this problem, you can create a directory into controller
dir called "admin". Inside it, you put your controller files in it,
specifying for each files the following header:
class Admin::EntryController < ApplicationController (for example)

For the views, you need to create an admin dir into the views dir.
This directory has the same arbo than a normal one.