I am trying to start my first project after going though the Depot
application in prog prog’s book. For some reason one of my migrations
keeps
bombing. I just try to setup a couple tables with some default
information
and even with changing the name of the second table and other minor
tweaks
it just does not work. I am connected to the db, the first table does
get
filled out.
Any help is appreciated!
Here is what I’ve done so far:
ruby script\generate model employees
ruby script\generate migration add_employee_data
ruby script\generate model cost_codes
ruby script\generate migration add_cost_code_data
Then inside the first 3 migrations everything goes ok -
001
class CreateEmployees < ActiveRecord::Migration
def self.up
create_table :employees do |t|
t.column :employee_number, :integer
t.column :name, :string
t.column :location, :string
t.column :department, :integer
t.column :company_code, :string
end
end
def self.down
drop_table :employees
end
end
002
class AddEmployeeData < ActiveRecord::Migration
def self.up
Employee.create(
:employee_number => ‘1234’,
:name => ‘Bob B’,
:location => ‘Office’,
:department => ‘07’,
:company_code => ‘003’)
end
def self.down
Employee.delete_all
end
end
003
class CreateCostCodes < ActiveRecord::Migration
def self.up
create_table :cost_codes do |t|
t.column :job, :integer
t.column :code, :integer
t.column :description, :string
end
end
def self.down
drop_table :cost_codes
end
end
This is the migration that fails with an error of ‘uninitalized constant
cost_code’ Anyone know what I am doing wrong?
004
class AddCodeCodeData < ActiveRecord::Migration
def self.up
Costcode.create(
:job => ‘0’,
:code => ‘5001’,
:description => ‘Other administrative (non-job related)’ )
end
def self.down
Costcode.delete_all
end
end