Moderately complex case - what's the r_c way to handle this?

0 views
Skip to first unread message

Greg Campbell

unread,
May 15, 2008, 2:34:03 PM5/15/08
to resource_controller
Here's the basic description of the domain I'd like to represent,
which has a few complications involved that I'm not sure how to
handle:

/locations/:id/resources/:resource_name/properties/:property_name/
values

A unique property can only be represented by the combination of
location id, resource name, and property name. On the backend,
though, there are currently only three ActiveRecord models represented
by the full path above: a location model, a combined resource+property
model (which belongs_to a location), and a value model. Thus, the
intermediate location/:id/resources path will be returning data that
doesn't directly map to an ActiveRecord model, and the full parent
chain for values objects will be the equivalent of
locations.find(:id).resource_properties.find_by_resource_name_and_property_name(res_name,
prop_name).values.

So: Does this require the deep nesting branch? What items will need
to be tweaked in the resources, properties, and values controllers to
handle the model situation described above? This is currently
planned to be a read-only API for accessing this data, so index and
show are the only two actions I need to support at the moment.

Apologies if I've missed some existing documentation that addresses
this kind of situation.

James Golick

unread,
May 17, 2008, 11:17:00 AM5/17/08
to resource_...@googlegroups.com
You could use the deep nesting branch, and override tons of stuff.

But, my reccomendation, instead, would be to just override the collection method (explained in the README) to do the find.

As long as the controller isn't polymorphic, and especially if you don't need creation/updating, that's the easiest way to do it.

Hope that helps,

J
Reply all
Reply to author
Forward
0 new messages