hi. base from the cookbook example, where each categories can have many recipes, id like the categories to have multiple sub categories, unlimited levels. please show some code, as i am new to Ruby and Ruby On Rails. thanks -- Posted via http://www.ruby-forum.com/.
Do you want the categories to behave like a tree? If so, check out acts_as_tree. http://api.rubyonrails.org/classes/ActiveRecord/Acts/Tree/ClassMethods.html#M000485 -Jonathan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060310/bbc49e19/attachment.html
cookbook app has one category > multiple recipes id like to have multiple sub categories, unlimietd levels. please show some code, as i am very new to ruby and rails. thanks. -- Posted via http://www.ruby-forum.com/.
no one could help me here? wanted to see if there''s a quickie way. thanks. -- Posted via http://www.ruby-forum.com/.
David Ang wrote:> no one could help me here? wanted to see if there''s a quickie way.The quick way is to have a look at acts_as_tree for the categories. In brief, you give your categories table a parent_id and tell the model that it acts_as_tree, and everything should fall into place. You''ll then need to figure out how you want to specify which category is the parent of a new one on creation. HTH -- Alex
hi alex. thanks very much. good thing ruby has these features. Alex Young wrote:> David Ang wrote: >> no one could help me here? wanted to see if there''s a quickie way. > The quick way is to have a look at acts_as_tree for the categories. In > brief, you give your categories table a parent_id and tell the model > that it acts_as_tree, and everything should fall into place. You''ll > then need to figure out how you want to specify which category is the > parent of a new one on creation. > > HTH-- Posted via http://www.ruby-forum.com/.
okay its hard. its not as easy as i thought does the acts as list has a scaffold code? or do i need to create my own "category page"? some code really would be very helpful. Alex Young wrote:> David Ang wrote: >> no one could help me here? wanted to see if there''s a quickie way. > The quick way is to have a look at acts_as_tree for the categories. In > brief, you give your categories table a parent_id and tell the model > that it acts_as_tree, and everything should fall into place. You''ll > then need to figure out how you want to specify which category is the > parent of a new one on creation. > > HTH-- Posted via http://www.ruby-forum.com/.
David Ang wrote:> okay its hard. its not as easy as i thought > > does the acts as list has a scaffold code? or do i need to create my own > "category page"? > > some code really would be very helpful.I haven''t tried it yet, but the Ajax scaffolding might be useful here, as might the Scaffolding Extensions... Google is your friend. -- Alex
David Ang
2006-Mar-14 13:35 UTC
[Rails] Re: Re: Re: multiple sub categories (parent-child)
hi alex i appreciate you helping me out the ajax scaffold is pretty nice http://ajaxscaffold.height1percent.com/ but alas, both stuff you mentioned, doesn''t incorporate acts_as_tree on their codes. Alex Young wrote:> David Ang wrote: >> okay its hard. its not as easy as i thought >> >> does the acts as list has a scaffold code? or do i need to create my own >> "category page"? >> >> some code really would be very helpful. > I haven''t tried it yet, but the Ajax scaffolding might be useful here, > as might the Scaffolding Extensions... Google is your friend.-- Posted via http://www.ruby-forum.com/.