Help: acts_as_versioned setup error "undefined local variabl

Hi All,

Rails newbie here trying to set up acts_as_versioned according to
Chapter 14
in the Rails Recipies book. I’ve taken the following steps (nearly
verbatim) as mentioned by the book:

  • created the target model “Post”
  • added the “acts_as_versioned” label to the model file
  • generated a migration file
  • added the table creation code and the command
    to the migration file
  • ran “rake migrate”

What I got is the error “undefined local variable or method ‘base_class’
Post:Class”. I tried with other models and kept getting the same error.
seems like “rake migrate” is missing the right environment setup, and
can’t find the Post class defined in the model file. Is there some step
I’ve overlooked?

Thanks a ton,

I’m having the same problem. I then tried renaming all my rake files to
make sure I didnt have any tasks that might be interferring with the
environment load. I think that helped me get a little further since it
dies on the “create_versioned_table” call. It also seems that the
acts_as_versioned method isn’t being called even though I have it at the
of my model file. It looks like “create_versioned_table” dies because
“versioned_table_name” (which is set in the main acts_as_versioned

Any help would be appreciated.


Has there been any progress on this? I’m having a similar problem
running my
rake migration for creating my versioned_table.


I’ve been harassed by this problem, but not consistently. I think,
that I’ve found a possible cause.

If you’re running emacs or some other development environement where you
could have multiple buffers open, some buffers may not be fresh views of
what’s actually on disk. If you run script/generate migrate or script/generate model …

… then you might have overwritten you model file, especially if you
hit enter whenever prompted. So that acts_as_versioned you see in your
might not be there.
Hope this saves someone the hour I just spent kicking every tire in my
before I finally found this.