Ancestry overrides acts_as_tree method even when acts_as_tree is installed #39

benevolentmadman opened this Issue Feb 17, 2011 · 5 comments

5 participants


I have model (X) using acts_as_tree, I want that model to continue using acts_as_tree. After adding ancestry to my Gemfile (for use in a different model (Y)), ancestry is now being called instead of acts_as_tree in X and failing my tests thusly:

undefined method `ancestry' for X

It appears that the following code is not working as expected:

if !respond_to?(:acts_as_tree)
    alias_method :acts_as_tree, :has_ancestry

I also have this issue. The thing is that because you never know the load order of a plugin that adds the acts_as_tree method. Because of this, using respond_to?(:acts_as_tree) will probably fail to detect such plugins/gems.

I forked the rep and added a check for the ActsAsTree module instead. This fixes the problem only if you're using a plugin that defines the module ActsAsTree. You can use my version by specifying [gem 'ancestry', :git => 'git://'] in your gemfile.

I'll add a pull request if the author wants to incorporate these changes :>


Fix by Jims was released in Ancestry 1.2.4. Thank you!


I still have problems with this issue. We are using the official acts_as_tree plugin from

This version doesn't define an ActsAsTree module, so the patch doesn't work. Maybe it would be better to let the developer interface these aliases via an initializer or macro configuration option? As an example I'd like to choose not to alias the acts_as_tree method at all, because I don't care about ancestry downwards compatibility.

has_ancestry :alias_acts_as_tree => false


hotsen, see the notice on that repository:

NOTICE: official repository moved to

See if that fixes the problem.


No sorry, it's the problem same there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment