Project

General

Profile

Help with Awesome Nested Set

Added by Juan David Duque over 13 years ago

I´m trying to build an issue´s importer and I need to set the parent to a new issue.
I can´t do it just by the field parent or parent_id of the issue, and I can´t figure out How to use the nested set.
I really need help with this matter, does anybody has a How to or an example that I can follow.
Thanks you !!


Replies (4)

RE: Help with Awesome Nested Set - Added by Felix Schäfer over 13 years ago

How are you trying to import issues: by SQL, by calling redmine methods on CLI, by...?

RE: Help with Awesome Nested Set - Added by Juan David Duque over 13 years ago

I´m using Redmine methods in my own plugin
Ex.
issue = Issue.new
issue.status_id = status
issue.priority_id = priority
issue.subject = subject
issue.project_id = project.id
...
issue.save

RE: Help with Awesome Nested Set - Added by Felix Schäfer over 13 years ago

Some documentation is available in here: source:/trunk/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb, basically you can't say "B's parent is A", but you have to say "B is A's child".

BUT the issue model knows a few more tricks, you will want to use Issue#parent_issue_id= for your plugin, see source:/trunk/app/models/issue.rb#L559

RE: Help with Awesome Nested Set - Added by Juan David Duque over 13 years ago

Done.
In Awesome nested set I can use the move_to_child_of(ID) method to set the parent of an issue, but this only work in the same tree of the issue to move. Probably I need to define the scoope to moved properly.
But I´m fine with the parent_issue_id method of models/issue.rb, I update the file to the latest commit and run some test, it´s working great.
Thanks a lot. !

    (1-4/4)