Colin A. Bartlett on 20 Sep 2007 23:30:24 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] RESTful controller overloading


Mort Goldman wrote:

I want to create each of the subtypes as resources, so that I could for example request a GET on Students.  At the same time, I’d like to only have one controller.  Has anyone tried doing this?

You could use Single Table Inheritance by creating model classes for Student, Teacher, and Administrator which all inherit from the Person class. By default, Active Record will use a field called "type" in the "people" table to store the name of the class the person belongs to. And, like much of AR, the rest just works magically.

Then your routes can be setup like any other resource.

-- 
Colin A. Bartlett
Kinetic Web Solutions
http://blog.kineticweb.com
_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk