Using Locomotive - Problem making database tables


Im using a macbook and Im still trying to get rails running properly!
I've went through the basic locomotive help file and have no problems
up until 'Prepare your database tables'.
Here is what im trying to do:

"Prepare your database tables

We will prepare our database using Migrations. Using migrations, you
code your table schemas in ruby. The migrations system is set up to
facilitate the evolution (and devolution!) of your schema over time

Select your application in the Locomotive main window and choose
Applications > Open Terminal
On the command line in the terminal type:
ruby script/generate migration add_monkeys_table

(The name you choose for your migration is not all that important to
rails; it should not include spaces and it should be meaningful to
Open the newly created '001_add_monkeys_table.rb' in db/migrate in your
favorite text editor. It should look something like this:
class AddMonkeysTable < ActiveRecord::Migration
  def self.up

  def self.down

Modify this code to look like this:
class AddMonkeysTable < ActiveRecord::Migration
  def self.up
    create_table :monkeys do |t|
      t.column :name, :string
      t.column :angry?, :boolean

  def self.down
    drop_table :monkeys

To create the table specified by this migration, from the command line
in the terminal (opened previously from Locomotive), type:
rake migrate

Success! Move on to generating scaffolding to make use of your new
database table."

No problems up until the step 6, rake migrate. Here is the error:

"c0a80004:~/Documents/work/depot jim$ ruby script/generate migration
      create db/migrate
      create db/migrate/001_add_monkeys_table.rb
c0a80004:~/Documents/work/depot jim$ rake migrate
(in /Users/jim/Documents/work/depot)
rake aborted!
Unknown database 'depot_development'

(See full trace by running task with --trace)
c0a80004:~/Documents/work/depot jim$ "

I can see it is obviously something with the database, I have a clean
install of mySQL installed as recommended on the locomotive site. Can
anyone help me identify what I am doing wrong so I can get coding with

Help much appreciated, thankyou in advance.

Then the question is exactly how do I manually create the database? Any
pointers on this. I'm finding it hard to understand how my locomotive
setup and my mysql setup (which allows me to do nothing other than run
it or turn it off) connect and how I get these databases and tables set

Any help is appreciated.
Alex Wayne wrote:

This procedure talks about MySQL 4, but the stuff like setting the root password has to be done with MySQL 5 too.

For creating databases:

For creating your table structure: use migrations that are automatically created in the db folder when generating models. Check the Rails API for instructions.

Thankyou for your comments. I know have mysql installed properly as far
as I can see.

How do I actually make these databases? I've installed CocaMysql2 and
when I try to make a new database for depot_development, to work with
the above that ive been trying to get working, im having problems.

From File > New, Ive completed the fields:

Host: localhost
User: root
Password: (i have added my password that i set following the mysql
Database: depot_development

I dont know about SSH Password etc so I havent completed that part.

When I try to connect it just errors 'connection failed'.

Out of the example on locomotive and also from the examples in a rails
book, it never seems to mention making the databases so i am completely
confused how to make them. Obviously I need to get this figured out!

Also just to check I have this right... After I have the databases made
I just need to set the details in config/database.yml and then I can
start creating my table structures using migrations?

Is there an easier way to make a database? Or can someone give me some
help making the requred databases to use with the above example.

Help greatly appreciated. I'm getting frustrated just trying to get
things set up so I can start coding!

Thanks for your help.


I would (very strongly) suggest using sqlite to start - you don't need
what mysql provides over sqlite at this point in your exploration of
rails (you may never need what mysql provides over sqlite!).
Configuring sqlite is also _substantially_ easier as the migration
_can_ create the database for sqlite.

Set up your database.yml to have (remove the username: password: etc
lines altogether)

  adapter: sqlite3
  database: db/dev.db

and you're done! Run the migration and it will create the db and the
tables. (The database will be the file /path/to/yourapp/db/dev.db)