Forum: Ruby on Rails How do you decide what controllers and actions to have?

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.
84e801aa2599cf03b96fcf074c951c7c?d=identicon&s=25 Josh Pigford (jpigford)
on 2006-03-18 18:10
I'm fairly new to RoR and am teaching myself by slowly converting one of
my sites (http://tutorialoutpost.com) to RoR from PHP. What I'm having
trouble with though is figuring out what controllers I should make and
what actions to use.

How do you plan all of it out? I'd had to start hacking away at this and
then come to find I had it all laid out wrong from the start.
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-03-18 23:53
Josh Pigford wrote:
> I'm fairly new to RoR and am teaching myself by slowly converting one of
> my sites (http://tutorialoutpost.com) to RoR from PHP. What I'm having
> trouble with though is figuring out what controllers I should make and
> what actions to use.
>
> How do you plan all of it out? I'd had to start hacking away at this and
> then come to find I had it all laid out wrong from the start.

The best way would be to see into what categories your data naturally
falls.

For example, if you're designing a blog, you might have controllers (and
most likely models) for entries, comments, and users, at the very least.
Also possibly tags or comments.  Those would be represented by schemas
in your database, so they'd be models, to encapsulate the data, and
controllers, to handle the logic.  If you have a variety of ways to
display your archive listings you might have an archives controller.

I got a blank page when I clicked on your site, but if it's a site with
a lot of tutorials, then you might have something similar: a model and
controller for the individual tutorial entries, for your users, for
comments or categories, or possibly for a listing of code examples.

On a shop site (like the Depot example in the excellent Agile Web
Development with Rails), you'd have a controller for users, and for
items to be sold, and to handle the administrative tasks of listing
items for sale.

Hope this helps,
Jeff Coleman
This topic is locked and can not be replied to.