Cynthia,
Thanks. I''ll try to require my model from my data migration.
To clarify my first question: the documentation on better_nested_set says that
"This plugin provides an enhanced acts_as_nested_set mixin for
ActiveRecord,
the object-db mapping layer of
the framework RubyOnRails."
Since a ''mixin'' is adding behavior dynamically to a certain
class, is better_nested_set adding its enhancements
directly to ActiveRecord or to acts_as_nested_set?
In the latter case, I would expect my plugin directory to need BOTH
acts_as_nested_set and
better_nested_set, because better_nested_set decorates acts_as_nested_set which
decorates ActiveRecord.
The decorator semantics would not be transitive.
In the former case, I would expect to simply use better_nested_set from my
app''s vendor/plugin directory, and
add the ''acts_as_nested_set'' incantation to my models. Here
the decorator semantics would be transitive.
Regards,
Alan
----- Original Message ----
From: Cynthia Kiser <cnk at caltech.edu>
To: Alan Wong <alan.wong at aya.yale.edu>; betternestedset-talk at
rubyforge.org
Sent: Thursday, July 3, 2008 2:57:18 AM
Subject: Re: [Betternestedset-talk] add migration
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
_______________________________________________
Betternestedset-talk mailing list
Betternestedset-talk at rubyforge.org
http://rubyforge.org/mailman/listinfo/betternestedset-talk