# Is there anything like recursive resources?

**URL:** <https://www.ruby-forum.com/t/is-there-anything-like-recursive-resources/141943>\
**Category:** Rails\
**Created:** [July 1, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/is-there-anything-like-recursive-resources/141943 "2008-07-01T23:24:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@tom-eric](https://www.ruby-forum.com/u/tom-eric)\
**Post date:** [July 1, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/is-there-anything-like-recursive-resources/141943/1 "2008-07-01T23:24:27Z")

</div>

Hi,

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  
end

class Folder \< ActiveRecord::Base  
acts\_as\_tree  
has\_many :folders  
end

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?

---

<div class="post-metadata">

**Author:** ![tom-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/57b2e6/32.png) [@tom-eric](https://www.ruby-forum.com/u/tom-eric)\
**Post date:** [July 2, 2008, 11:26am UTC](https://www.ruby-forum.com/t/is-there-anything-like-recursive-resources/141943/2 "2008-07-02T11:26:12Z")

</div>

On 01 Jul 2008, at 23:24, Tom-eric Gerritsen wrote:

> end
> 
> 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
