Help: acts_as_versioned setup error "undefined local variabl


#1

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
    “Post.create_versioned_table”
    to the migration file
  • ran “rake migrate”

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

Thanks a ton,
John

http://www.twobitoperation.com


#2

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
now
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
top
of my model file. It looks like “create_versioned_table” dies because
the
“versioned_table_name” (which is set in the main acts_as_versioned
method).

Any help would be appreciated.

Thanks,
Justin


#3

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

Steve
http://www.smarkets.net


#4

I’ve been harassed by this problem, but not consistently. I think,
however,
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
just
hit enter whenever prompted. So that acts_as_versioned you see in your
code
might not be there.
Hope this saves someone the hour I just spent kicking every tire in my
code
before I finally found this.
Trevor