Rails List
2009-Aug-19 13:19 UTC
acts_as_list / acts_as_tree / acts_as_nested_set - which one
I am creating forum application which needs usage of acts_as_list or acts_as_tree or acts_as_nested_set. I am unable to decide among these. please could some one recommend from their experience? -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Aug-19 13:25 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which one
Rails List wrote:> I am creating forum application which needs usage of acts_as_list or > acts_as_tree or acts_as_nested_set. > > I am unable to decide among these. please could some one recommend from > their experience?Don''t use acts_as_tree -- its data structure is simple but inefficient for querying. Use awesome_nested_set instead. Depending on what you''re doing, acts_as_list may be useful as well (and it works in conjunction with awesome_nested_set). Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Rails List
2009-Aug-19 15:39 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Marnen Laibow-Koser wrote:> Rails List wrote: >> I am creating forum application which needs usage of acts_as_list or >> acts_as_tree or acts_as_nested_set. >> >> I am unable to decide among these. please could some one recommend from >> their experience? > > Don''t use acts_as_tree -- its data structure is simple but inefficient > for querying. Use awesome_nested_set instead. Depending on what you''re > doing, acts_as_list may be useful as well (and it works in conjunction > with awesome_nested_set). > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgThanks Marnen, I have had a look at awesome_nested_set. It follows the Rails Plugin tradition of not having sufficient tutorial that a beginner can understand. Could you recommend some tutorial for awesome_nested_set? Craigslist Clone www.railslist.com -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Aug-19 16:10 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Rails List wrote: [...]> Thanks Marnen, I have had a look at awesome_nested_set. It follows the > Rails Plugin tradition of not having sufficient tutorial that a beginner > can understand. Could you recommend some tutorial for > awesome_nested_set?No, because I don''t know of one either. But the rdoc is pretty good (you may need to build it yourself, though). Reading some general articles on nested sets might help too. Honestly, tutorials are great, but if you need them for everything you do, you''re not going to get very far.> > Craigslist Clone > www.railslist.comBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Gleb Mazovetskiy
2009-Aug-19 16:18 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
It does have a tutorial somewhere in Wiki section of github, as long as I remember. But all you really need is to install it, declare :lft, :rgt, and :parent_id in the migration, and put act_as_nested_set in the model. Not hard at all. However, note that you should recreate all the existing instances of the model, so that :lft and :rgt fields will be set. Cheers, Gleb P.S.: From my code: class MakePlaylistsNested < ActiveRecord::Migration def self.up add_column :playlists, :parent_id, :integer add_column :playlists, :lft, :integer add_column :playlists, :rgt, :integer end def self.down remove_column :playlists, :parent_id, :lft, :rgt end end class Playlist < ActiveRecord::Base acts_as_nested_set :scope => :user_id, :depenendent => :destroy ... end -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Aug-19 17:41 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
On Aug 19, 12:18 pm, Gleb Mazovetskiy <rails-mailing-l...@andreas- s.net> wrote:> It does have a tutorial somewhere in Wiki section of github, as long as > I remember. > > But all you really need is to install it, declare :lft, :rgt, and > :parent_id in the migration, and put act_as_nested_set in the model. Not > hard at all.Right.> However, note that you should recreate all the existing instances of the > model, so that :lft and :rgt fields will be set.That''s unnecessary. You can just walk the tree and set them appropriately (this is best done in the migration). Or even easier, just call Model.rebuild! . See http://bit.ly/gVr7Q .> > Cheers, > GlebBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
Rails List
2009-Aug-19 18:21 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Are these acts_as_* are external plugins or are they built in with active record? -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Aug-19 18:23 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Rails List wrote:> Are these acts_as_* are external plugins or are they built in with > active record?They''re gems and plugins that you''ll have to install. I think acts_as_list and acts_as_tree used to be part of AR, but they no longer are. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Rails List
2009-Aug-19 19:42 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Marnen Laibow-Koser wrote:> Rails List wrote: >> Are these acts_as_* are external plugins or are they built in with >> active record? > > They''re gems and plugins that you''ll have to install. I think > acts_as_list and acts_as_tree used to be part of AR, but they no longer > are. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgdownloaded awsome plugin. created a table forum with parent_id, lft, rgt and comments. generated scaffold for forum now i am able to insert parent items ( ie whose parent_id is null). How do I insert a child?. -- Posted via http://www.ruby-forum.com/.
Gleb Mazovetskiy
2009-Aug-20 00:11 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Create the item, and then use item.move_to_child_of(parent) method. Manual: http://wiki.github.com/collectiveidea/awesome_nested_set/awesome-nested-set-cheat-sheet -- Posted via http://www.ruby-forum.com/.
Rails List
2009-Aug-20 05:51 UTC
Re: acts_as_list / acts_as_tree / acts_as_nested_set - which
Gleb Mazovetskiy wrote:> Create the item, and then use item.move_to_child_of(parent) method. > Manual: > http://wiki.github.com/collectiveidea/awesome_nested_set/awesome-nested-set-cheat-sheetSuperb Thank you Craigslist Clone http://www.classifiedscript.in -- Posted via http://www.ruby-forum.com/.