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?

Rails L. 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
[email protected]

Marnen Laibow-Koser wrote:

Rails L. 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
[email protected]

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?

Craigslist Clone
www.railslist.com

Rails L. 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.com

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Aug 19, 12:18 pm, Gleb M. <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,
Gleb

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Are these acts_as_* are external plugins or are they built in with
active record?

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

Marnen Laibow-Koser wrote:

Rails L. 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
[email protected]

downloaded 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?.

Rails L. 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
[email protected]

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

Gleb M. 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-sheet

Superb Thank you

Craigslist Clone
http://www.classifiedscript.in

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs