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

S

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 ;-)

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
 
A

Austin Ziegler

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 ;-= )

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?

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

-austin
 
D

Dave Burt

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
 
B

Bruno Celeste

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 ;-= )

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top