Josh Pigford
2006-Mar-18 17:10 UTC
[Rails] How do you decide what controllers and actions to have?
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. -- Posted via http://www.ruby-forum.com/.
Jeff Coleman
2006-Mar-18 22:53 UTC
[Rails] Re: How do you decide what controllers and actions to have?
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 -- Posted via http://www.ruby-forum.com/.
Apparently Analagous Threads
- How would I get the previous id from the database?
- Strange Unit Testing error - newbie question
- What do I need to learn Ruby, Rails, JavaScript, AJAX?
- Agile book apache2.conf: Forbidden You don't have permission to access / on this server.
- Having trouble listing tiers of categories