views:

802

answers:

1

Hi,

I created a model ruby script/generate model Article (simple enuff)

Here is the migration file create_articles.rb:

def self.up
  create_table :articles do |t|
    t.column :user_id, :integer
    t.column :title, :string
    t.column :synopsis, :text, :limit => 1000
    t.column :body, :text, :limit => 20000
    t.column :published, :boolean, :default => false
    t.column :created_at, :datetime
    t.column :updated_at, :datetime
    t.column :published_at, :datetime
    t.column :category_id, :integer
  end

def self.down
  drop_table :articles
 end
end

When I run the rake:db migrate command I receive an error rake aborted! "Uninitialized constant CreateArticles."

Does anyone know why this error keeps happening?

+8  A: 

Be sure that your file name and class name say the same thing(except the class name is camel cased).The contents of your migration file should look something like this, simplified them a bit too:

#20090106022023_create_articles.rb
class CreateArticles < ActiveRecord::Migration   
  def self.up
    create_table :articles do |t|
      t.belongs_to :user, :category
      t.string :title
      t.text :synopsis, :limit => 1000
      t.text :body, :limit => 20000
      t.boolean :published, :default => false
      t.datetime :published_at
      t.timestamps
    end
  end

  def self.down
    drop_table :articles
  end
end
thetacom
Thank You thetacom!!!! You da man dude. How stupid can i be?
featureBlend
We all have our moments.
thetacom
Too many `end`s - but then so did the original paste
Gareth