# Help: acts\_as\_versioned setup error "undefined local variabl

**URL:** <https://www.ruby-forum.com/t/help-acts-as-versioned-setup-error-undefined-local-variabl/55338>\
**Category:** Rails\
**Created:** [March 20, 2006, 2:50am UTC](https://www.ruby-forum.com/t/help-acts-as-versioned-setup-error-undefined-local-variabl/55338 "2006-03-20T02:50:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac8455/32.png) [@john\_li](https://www.ruby-forum.com/u/john_li)\
**Post date:** [March 20, 2006, 2:50am UTC](https://www.ruby-forum.com/t/help-acts-as-versioned-setup-error-undefined-local-variabl/55338/1 "2006-03-20T02:50:57Z")

</div>

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

> **[Two-Bit Operation LLC](http://www.twobitoperation.com)**
>
> How to Start a Two-Bit Operation, From start to small business.

---

<div class="post-metadata">

**Author:** ![john\_li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac8455/32.png) [@john\_li](https://www.ruby-forum.com/u/john_li)\
**Post date:** [March 21, 2006, 2:17am UTC](https://www.ruby-forum.com/t/help-acts-as-versioned-setup-error-undefined-local-variabl/55338/2 "2006-03-21T02:17:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john\_li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac8455/32.png) [@john\_li](https://www.ruby-forum.com/u/john_li)\
**Post date:** [March 23, 2006, 6:03pm UTC](https://www.ruby-forum.com/t/help-acts-as-versioned-setup-error-undefined-local-variabl/55338/3 "2006-03-23T18:03:16Z")

</div>

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](http://www.smarkets.net)

---

<div class="post-metadata">

**Author:** ![john\_li](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac8455/32.png) [@john\_li](https://www.ruby-forum.com/u/john_li)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/help-acts-as-versioned-setup-error-undefined-local-variabl/55338/4 "2006-08-15T14:18:40Z")

</div>

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
