how to run custom plugin code AFTER project tree hierarchy update
Added by Maciej Liżewski almost 11 years ago
Ok. I created plugin which adds after_create and after_save handlers in project AR model.
the problem is that those triggers are fired BEFORE nested set hierarchy is updated (insert new project or move current project in tree)...
the plugin has to copy project information to another database, which we need for some reasons. how can I force my plugin to run some custom trigger after the nested set hierarchy is updated and project model update is finished (other triggers/handlers that could change its data must be run BEFORE my handler)
any help appreciated
Replies (3)
RE: how to run custom plugin code AFTER project tree hierarchy update
-
Added by Andriy Lesyuk almost 11 years ago
You can use after_move
, which is provided by the awesome_nested_set
(the one, which is used for project hierarchy). But note, that after_move
is not always executed (as I remember), so you may need to update the another db twice.
RE: how to run custom plugin code AFTER project tree hierarchy update
-
Added by Maciej Liżewski almost 11 years ago
wow, that would be great. I have no problem with several calls (in after_save and after_move).
But could you confirm that there is such handler and from which version, because I cannot find "after_move" literal anywhere in my redmine sources (we are currently running Redmine 2.2.3.stable)?
RE: how to run custom plugin code AFTER project tree hierarchy update
-
Added by Andriy Lesyuk almost 11 years ago
Maciej Liżewski wrote:
But could you confirm that there is such handler and from which version, because I cannot find "after_move" literal anywhere in my redmine sources (we are currently running Redmine 2.2.3.stable)?
Yes, I can confirm! As I use it in Project Sections plugin, that supports Redmine 1.4.x - 2.3.x.
In current Redmine (and in 2.2.x, I guess) such callbacks are created using define_model_callbacks
. See source:/trunk/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb