Forum: Ruby on Rails Migration fails when using certain table name

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Tom B. (Guest)
on 2006-03-30 01:53
I'm trying to do this migration, but it fails when I try to create a
default content using Section.create I get an error saying 'unitialized
contant Section'
The weird thing is if I use a table name like 'categories' with
Category.create instead of 'sections' and Section.create then it all
works fine! I'm working from Rails 1.1

This is an example migration that fails:

class InitialSetup < ActiveRecord::Migration
  def self.up

    # Page sections table
    create_table :sections do |t|
      t.column "title",       :string,    :limit => 60
      t.column "link",        :string,    :limit => 60
      t.column "page_title",  :string
      t.column "keywords",    :string

    # Default content
    Section.create :title => "Home", :link => "home"


  def self.down
    drop_table :sections


Error: 'unitialized contant Section'.

But use create_table :categories and Category.create and it all works.
Am I missing something glaringly obvious here?
Chris C. (Guest)
on 2006-03-30 01:56
Are you sure you defined a model named Section ?
Tom B. (Guest)
on 2006-03-30 02:00
Christophe G. wrote:
> Are you sure you defined a model named Section ?

Doh! Thanks Christophe, as you can see I'm very new to this! I had a
category controller, but forgot to rename it to section when I decided
to rename the DB table.
Cheers :)
This topic is locked and can not be replied to.