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 end # Default content Section.create :title => "Home", :link => "home" end def self.down drop_table :sections end end ===== Error: ''unitialized contant Section''. But use create_table :categories and Category.create and it all works. Am I missing something glaringly obvious here? -- Posted via http://www.ruby-forum.com/.
Christophe Gimenez
2006-Mar-29 22:40 UTC
[Rails] Re: Migration fails when using certain table name
Are you sure you defined a model named Section ? -- Posted via http://www.ruby-forum.com/.
Tom Beddard
2006-Mar-29 22:42 UTC
[Rails] Re: Migration fails when using certain table name
Christophe Gimenez 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 :) -- Posted via http://www.ruby-forum.com/.