# Help w/ rake db:migrate error

**URL:** <https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971>\
**Category:** Rails\
**Created:** [February 21, 2009, 5:11pm UTC](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971 "2009-02-21T17:11:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [February 21, 2009, 5:11pm UTC](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971/1 "2009-02-21T17:11:26Z")

</div>

I made a few changes to my migration files, dropped all tables (rake  
db:drop:all), and when I went to re-create everything (rake  
db:migrate), I get this:

rake db:migrate --trace  
(in /Users/Eric/Development/Work/Rails/pcod)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
rake aborted!  
undefined method `random' for Tidbit(Table doesn't exist):Class /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/ base.rb:1833:in`method\_missing\_without\_paginate’  
/Users/Eric/Development/Work/Rails/pcod/vendor/plugins/will\_paginate/  
lib/will\_paginate/finder.rb:167:in `method_missing' /Users/Eric/Development/Work/Rails/pcod/app/controllers/application.rb: 6 /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:382:in`load\_without\_new\_constant\_marking’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
dependencies.rb:382:in `load_file' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:521:in`new\_constants\_in’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
dependencies.rb:381:in `load_file' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:256:in`require\_or\_load’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
dependencies.rb:221:in `depend_on' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:133:in`require\_dependency’  
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action\_controller/  
dispatcher.rb:18:in `define_dispatcher_callbacks' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ callbacks.rb:182:in`call’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
callbacks.rb:182:in `evaluate_method' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ callbacks.rb:166:in`call’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
callbacks.rb:90:in `run' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ callbacks.rb:90:in`each’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
callbacks.rb:90:in `send' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ callbacks.rb:90:in`run’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
callbacks.rb:277:in `run_callbacks' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:559:in`send’  
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:559:in  
`prepare_dispatcher' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:173:in`process’  
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in  
`send' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in`run’  
/Users/Eric/Development/Work/Rails/pcod/config/environment.rb:13  
/Library/Ruby/Site/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in`require’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
dependencies.rb:153:in `require' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:521:in`new\_constants\_in’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active\_support/  
dependencies.rb:153:in `require' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/tasks/misc.rake:3 /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in`call’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in`each’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in`invoke\_with\_call\_chain’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
1.8/monitor.rb:242:in `synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in`invoke\_with\_call\_chain’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:588:in  
`invoke_prerequisites' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in`each’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:585:in  
`invoke_prerequisites' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:577:in`invoke\_with\_call\_chain’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
1.8/monitor.rb:242:in `synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in`invoke\_with\_call\_chain’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in`invoke\_task’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in`each’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in`standard\_exception\_handling’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in`run’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in  
`standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in`run’  
/Library/Ruby/Gems/1.8/gems/rake-0.8.3/bin/rake:31  
/usr/bin/rake:19:in `load’  
/usr/bin/rake:19

I took out the “random” function mentioned in the trace because it was  
initially complaining about that method referencing a table that  
doesn’t exist. Well, of course it doesn’t – I just dropped the  
tables. But the real question is, why is that method being called in  
the first place? Any suggestions on how to resolve this?

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [February 21, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971/2 "2009-02-21T17:13:12Z")

</div>

Also, I’m running SQLite3 locally and tried deleting the  
development.sqlite3 database manually, as well as the generated  
schema.rb file.

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [February 21, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971/3 "2009-02-21T17:48:41Z")

</div>

Found my problem. I had the line $random\_tidbit = Tidbit.random in my  
application.rb. This was causing the problem. I need a way to define  
random\_tidbit available in my application.rhtml without having to  
place instance variables for random\_tidbit inside of each controller.  
@random\_tidbit in application.rb didn’t work, so we temporarily went  
with a global variable solution.

How should I do this instead?

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [February 23, 2009, 1:06am UTC](https://www.ruby-forum.com/t/help-w-rake-db-migrate-error/160971/4 "2009-02-23T01:06:43Z")

</div>

What’s the goal? Using a global will mean that in production mode,  
$random\_tidbit  
will only ever be set once. Even worse, if you’re running a setup with  
multiple instances  
(pretty much any modern deployment), each one will get a _different_  
value. Do you  
want the value to be different for each request?

–Matt J.
