RESTful nested resources and polymorphism?

With ref to my previous post: RESTful app and refactoring code in different controllers - Rails - Ruby-Forum
I am now able to access items from topics controller. However, now I
need to add sub-item e.g.: An item itself could have many sub-items. So
my items model is like:
class Item < ActiveRecord::Base
validates_uniqueness_of :title, :scope => [:topic_id]
validates_presence_of :topic_id, :title, :owner, :position

belongs_to :topic
belongs_to :parent,
:class_name => “Item”,
:foreign_key => “parent_id”
has_many :children,
:class_name => “Item”,
:foreign_key => “parent_id”,
:order => :position,
:dependent => :destroy #don’t leave orphans (cascade delete)
has_many :attachments,
:dependent => :destroy #don’t leave orphans (cascade delete)
end

My config/routes.rb file is:
map.resources :topics do |topics|
topics.resources :items do |items|
items.resources :attachments
end
end

Now, if I need to create a new subitem then what changes should I make
to my routing file? And what will be the form of RESTful urls?

Thanks,
CS.

Bump up…

I think I mean to say self-referential rather than polymorphism…

Sorry…

CS.

Carlos S. wrote:

With ref to my previous post: RESTful app and refactoring code in different controllers - Rails - Ruby-Forum
I am now able to access items from topics controller. However, now I
need to add sub-item e.g.: An item itself could have many sub-items. So
my items model is like:
class Item < ActiveRecord::Base
validates_uniqueness_of :title, :scope => [:topic_id]
validates_presence_of :topic_id, :title, :owner, :position

belongs_to :topic
belongs_to :parent,
:class_name => “Item”,
:foreign_key => “parent_id”
has_many :children,
:class_name => “Item”,
:foreign_key => “parent_id”,
:order => :position,
:dependent => :destroy #don’t leave orphans (cascade delete)
has_many :attachments,
:dependent => :destroy #don’t leave orphans (cascade delete)
end

My config/routes.rb file is:
map.resources :topics do |topics|
topics.resources :items do |items|
items.resources :attachments
end
end

Now, if I need to create a new subitem then what changes should I make
to my routing file? And what will be the form of RESTful urls?

Thanks,
CS.