Quoting Alan Wong <alan_kt_wong at yahoo.com>:> I''m trying to use the better nested set plugin for the Category
model for my CMS application.
>
> Since I want to start on the right foot, my Category model will act as a
nested set.
> I do all the standard Rails generation work. I generate a model called
Category. Modify
> a create_categories migration to create a table. Add validation logic to my
Category model.
> Finally I am trying to prepopulate my database with data.
>
> I''m having trouble with the last step, as migrations seems to
reject the method, ''move_to_child_of''
>
> newborn = Category.new(:name =>"new")
> newborn.save
> newborn.move_to_child_of root
>
> A few questions
> 1) Does better_nested_set require that I already have acts_as_nested_set
installed for me to use it?
>
> 2) Why can''t I run better_nested_set methods from migrations?
>
> BTW, I''m using Rails 2 and Ruby 1.8
Not clear what you are asking in #1 but #2 is probably that the
migration doen''t know Category is defined as a nested set. If you have
already added the ''acts_as_nested_set'' incantation to your
model file
before trying to run you migration the first time, then try the trick
of defining the class within your migration file - after create the
table but before you want to populate it.
same issue (I think), different manifestation:
http://blog.8thlight.com/articles/2008/06/14/active-record-migration-dependancies