collectiveidea/awesome_nested_set — Issue #117: Heroku ActiveRecord::ActiveRecordError (Impossible move, target node cannot be inside moved tree.
Author: driki
Created: 2012-01-30 01:53:14+00:00
State: open

Hi,

I'm getting the following error while using awesome_nested_set in Heroku. I do not see the same problem while running my app locally in development with mysql. Hoping that someone can help out.

I have the following method

def create_stub_project
project = Project.new

project.organization_id = self.id
project.title = ""
project.description = ""
project.summary = ""
project.year = Time.now.year.to_i
project.expense_budget = 0
project.revenue_budget = 0
project.average_tax_bill = 0
project.published = true
project.save!

# Based on the Maine Muni Fiscal Survey
# There are parent categories and sub-categories
# These are Expense categories
expense_parent_categories = Hash.new
expense_parent_categories["General Admin"] = ["Employee Benefits",
"Elected Officials",
"Admin Offices",
"Legal",
"Government Buildings",
"Economic Development"]
expense_parent_categories["Public Safety"] = ["Police",
"Fire",
"EMS",
"Street Lighting",
"Other",
"Capital"]

# create the parent categories
expense_parent_categories.each do |parent_category|
parent = Category.new
parent.name = parent_category.first
parent.goal = ""
parent.description = ""
parent.challenge = ""
parent.expense_budget = 0
parent.revenue_budget = 0
parent.tag_list = "expense"
parent.save
project.categories << parent
project.save

# now add the descendents
parent_category[1].each do |child_category|
child = Category.new
child.name = child_category
child.goal = ""
child.description = ""
child.challenge = ""
child.expense_budget = 0
child.revenue_budget = 0
child.tag_list = "expense"
child.save
child.move_to_child_of(parent)
child.save
end
end
self.projects << project
self.save
end

When I run this locally in development I do not hit the error mentioned in the subject. When running in production on Heroku I do.

Thoughts?

Thanks,
Matt