Hello Guys,
Yesterday i phase one problem regarding positioning with legacy database. For my rails application i have used the awesome_nested_set to manage nesting/threading. Case is to rearrange the position and for that i have used pretty nice method called 'rebuild!'.
Assume i have model called 'Post' and have nesting per Category .
# id: integer
# category_id: integer
# lft :integer
# parent_id :integer
# position :integer
# rgt :integer
class Post < ActiveRecord::Base
acts_as_nested_set :scope => :category
end
In the legacy database, having 3 categories called 'Alpha', 'Beta', 'Gama'. In which category Alpha's data mess out.
To over come this problem invoke command on console.
> script/console
> category = Category.find_by_name('Alpha')
> category.posts.rebuild!
Now cross check the data and it results as per need. Hope this post is helpful to you guys. Cheers!!