With ref to my previous post: http://www.ruby-forum.com/topic/180356
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.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to