The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Model and Controller Names

Just wondering what is recommended for model and controller names. For example, i want to build a site for that has car sales so I might want to call my controller 'cars_for_sale'. I would want something like this because it's more descriptive than say 'classifieds' and would work better for readability in the URL.

Can I call my controller car_sales and if so how will this affect rails conventions of using the singular controller name when creating controllers and models.

It is probably easiest to start by defining your models before you start thinking about your controllers. So start by defining the objects you are modelling.

For example, if you decide that all you have are cars and that when sold all that happens is that a property status changes to sold then I think the convention would point towards you calling the controller "cars" and then you having a "for_sale" view that would list all cars where the status is not sold.

However, if you find that "a sale" is itself an object (perhaps mimicing an invoice or sales note) and therefore you have car and sale objects, things get a little more complicated. By convention I think you'd probably then have a sales and a cars controller depending which object you were providing view or actions upon.

Which ever way, if you needed a "/cars_for_sale" URL, you'd create a route that would direct the system to the relevant controller and view. Therefore, the desired URL does not have to dictate the controller name.