db migration:

When creating several tables in one migration, put them all in the same class. Give the class the same name as the migration. For example:

file: 001_create_tables.rb

class CreateTables < ActiveRecord::Migration

  def self.up

    create_table :sites do |t|
      t.string      :name     
      t.integer     :group_id,      :null => true
      t.integer     :moh_id                      
      t.integer     :playlist_id                 
      t.timestamps                               
    end                                          

    create_table :songs do |t|
      t.string         :title 
      t.integer        :site_id,     :null => true
      t.timestamps                                
    end                                           

    create_table :groups do |t|
      t.string        :name    
      t.timestamps             
    end

    create_table :playlists do |t|
      t.string       :name
      t.integer      :song_id,    :null => true
      t.timestamps
    end
  end

  def self.down
    drop_table :sites
    drop_table :songs
    drop_table :groups
    drop_table :playlists
  end

end

If several migrations are placed into one file like this:

files: 001_create_tables.rb


class CreateSites < ActiveRecord::Migration
  def self.up

    create_table :sites do |t|
      t.string            :name
      t.integer           :group_id,         null => true
      t.integer           :moh_id
      t.integer           :playlist_id
      t.timestamps
    end

  def self.down
    drop_table :sites
  end

end

class CreateSongs < ActiveRecord::Migration
  def self.up
    create_table :songs do |t|
    end

  def self.down
    drop_table :songs
  end

end

… etc

Then this error is likely: uninitialized constant CreateTables

(I guess because there wasn’t a class called “CreateTables” in the create_tables migration.)