# Very Stuck

**URL:** <https://www.ruby-forum.com/t/very-stuck/107925>\
**Category:** Rails\
**Created:** [June 27, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/very-stuck/107925 "2007-06-27T16:56:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [June 27, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/very-stuck/107925/1 "2007-06-27T16:56:13Z")

</div>

Ok I have been trying to get started with Ruby on Rails and I want to  
tie it together with a mysql database. I have been using the  
examples in teh Agile Web Developkent with Rails, which has you setup  
the database.yml file and run rake db:migrate to make sure you can  
connect.

Well this all works great.

Next you create a model using script/generate model Account

Once this is created if you run rake db:migrate it will fail. Giving  
you an unitialized constant CreateAccount error.

After doing some research online it appears the the file that is  
generated is named wrong and that is much exactly match the name of  
the class definition inside the migration file.  
The generated file is 001\_create\_accounts.rb

/\*\*\*\*\*\*\*\*\*\*\*\* Migration File 001\_create\_accounts.rb  
class CreateAccounts \< ActiveRecord::Migration  
def self.up  
create\_table :accounts do |t|  
end  
end

def self.down  
drop\_table :accounts  
end  
end

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

I renamed the file to 001\_CreateAccounts.rb, however now I get this :

vincent-cordaros-computer:~/Development/WorkSpace/rails/mymeetingstone  
Storm$ rake db:migrate – trace  
(in /Users/Storm/Development/WorkSpace/rails/mymeetingstone)

* * *

```
  * config.breakpoint_server has been deprecated and has no

```

effect. \*

* * *

rake aborted!  
You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.first

Anyone have any ideas or can point me to a good working code example.  
I just really want to leverage the object relational mapping  
of Rails.

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [June 27, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/very-stuck/107925/2 "2007-06-27T17:16:15Z")

</div>

Vince wrote:

> Once this is created if you run rake db:migrate it will fail. Giving  
> def self.up

The generated filename is correct, and it looks right to me. My first  
suspicion was that you were migrating an empty table, but I just tried  
and that works for me. The error you’re getting doesn’t really suggest  
a DB problem to me, it suggests some other problem with your rails  
setup. How did you install Rails? following the instructions at  
[rubyonrails.org](http://rubyonrails.org)? or are you using Instant Rails? Or if you’re on linux,  
did you use a package manager?

–  
[http://www.5valleys.com/](http://www.5valleys.com/)

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [June 27, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/very-stuck/107925/3 "2007-06-27T21:00:45Z")

</div>

Once you migrate the db(rake db:migrate), you can’t rename the  
migration or add anything to it. You have to generate a new migration,  
script/generate model Accounts, then db:migrate and it should work.

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [June 27, 2007, 9:37pm UTC](https://www.ruby-forum.com/t/very-stuck/107925/4 "2007-06-27T21:37:48Z")

</div>

jg wrote:

> Once you migrate the db(rake db:migrate), you can’t rename the  
> migration or add anything to it. You have to generate a new migration,  
> script/generate model Accounts, then db:migrate and it should work.

As I understand, he said it “failed” the first time, with an  
Uninitialized Constant error. The problem isn’t trying to rename it  
after running it. The problem is trying to get it to run successfully  
the first time.

–  
[http://www.5valleys.com/](http://www.5valleys.com/)
