Is there anything like recursive resources?


I'm trying to create a virtual file system in rails with folders and
documents. My models look a bit like this:

class Document < ActiveRecord::Base
  belongs_to :folder

class Folder < ActiveRecord::Base
  has_many :folders

Now, what I really want is a RESTful interface to access the data in the
database. So I can do stuff like DELETE
/folders/1/folders/2/folders/3/files/1, or even better: DELETE
/folder-name-1/folder-name-2/folder-name-3/some-file.txt. Is there
anyway to accomplish this in Rails, or are there any plugins that can
help me accomplish this?

I don’t know if it handles self referential associations well (and you should try to avoid more than 2 levels of associations in your url anyway imho, but check out the resource_controller plugin (not the resources_controller plugin, watch the singular/plural “s”). Maybe make_resourceful does it too these days, but we have opted for resource_controller and it has been great for us.

Best regards

Peter De Berdt