Mike Mangino on 21 Sep 2007 01:09:01 -0000


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

Re: [PhillyOnRails] RESTful controller overloading


Mort, I've done something like this. You can use

map.resources :students, :controller => "people"

You will probably need to have a type field in your form. This also will allow people to view students via the teachers resource. If that is a problem, you can pass a type of role parameter and use params [:role].classify.constantize to get the appropriate class to use for finders.

Mike

On Sep 20, 2007, at 1:38 PM, Mort Goldman wrote:

I’ve got a few resources which are probably best represented as generalization hierarchies – as a simple example let’s say you have Students, Teachers, and Administrators who are all subtypes of Persons. In the standard denormalization process I collapsed the subtypes into the supertype and only created the model / table for Person/People with a role attribute.



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? Seems there should be an easy way to set up routes to handle this, but I’m not seeing it.



Thanks,

Mort



Mort Goldman

Principal

408 West, LLC

www.408west.com

mort.goldman@408west.com

610.715.9006



_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk

-- Mike Mangino http://www.elevatedrails.com



_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk