title: Why am I getting an "uninitialized constant RefineryPage" when trying to seed after adding Refinery CMS
body: <p>I've added RefineryCMS 2.0.3 to an existing (prelaunch, so I can smoke the db) app. I had a number of issues in upgrading to Devise 2.0 and rails 3.2 but I have gotten past them enough where the app will start. I've unfortunately hit a roadblock with Refinery though.</p>
  
  <p>If I seed or if I attempt to create a page, I run into the error listed below. I've double checked and all of the migrations appear to be included (attached) and all that are are up. The database schema (partially attached) seems to be in working order. </p>
  
  <p>The only thing I can think of is that maybe a gem is conflicting, but I'm not sure how. I've added my gemfile incase anyone more familiar with Rails can spot it.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p><strong>error when attempting to run rake db:seed</strong></p>
  
  <pre><code>rake db:seed --trace
  ** Invoke db:seed (first_time)
  ** Execute db:seed
  ** Invoke db:abort_if_pending_migrations (first_time)
  ** Invoke environment (first_time)
  ** Execute environment
  ** Execute db:abort_if_pending_migrations
  rake aborted!
  uninitialized constant RefineryPage
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:229:in `block in constantize'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `each'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `constantize'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/active_scaffold-3.2.3/lib/active_scaffold/extensions/reverse_associations.rb:34:in `block in autodetect_inverse'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/active_scaffold-3.2.3/lib/active_scaffold/extensions/reverse_associations.rb:26:in `each'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/active_scaffold-3.2.3/lib/active_scaffold/extensions/reverse_associations.rb:26:in `autodetect_inverse'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/active_scaffold-3.2.3/lib/active_scaffold/extensions/reverse_associations.rb:15:in `inverse_of_with_autodetect'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/associations/association.rb:212:in `inverse_reflection_for'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/associations/association.rb:217:in `invertible_for?'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/associations/association.rb:108:in `set_inverse_instance'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:351:in `add_to_target'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:112:in `build'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/associations/collection_proxy.rb:46:in `build'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/instance_methods.rb:134:in `translation_for'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/adapter.rb:77:in `fetch_attribute'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/adapter.rb:24:in `block in fetch'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/adapter.rb:23:in `each'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/adapter.rb:23:in `fetch'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/instance_methods.rb:67:in `read_attribute'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/class_methods.rb:114:in `block in translated_attr_accessor'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activemodel-3.2.3/lib/active_model/dirty.rb:154:in `attribute_will_change!'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/instance_methods.rb:49:in `write_attribute'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/class_methods.rb:111:in `block in translated_attr_accessor'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/attribute_assignment.rb:78:in `each'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
  (eval):3:in `block in assign_attributes'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/globalize3-0.2.0/lib/globalize/active_record/instance_methods.rb:170:in `with_given_locale'
  (eval):3:in `assign_attributes'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/base.rb:498:in `initialize'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/validations.rb:39:in `new'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/validations.rb:39:in `create!'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/refinerycms-pages-2.0.3/db/seeds.rb:2:in `&lt;top (required)&gt;'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:520:in `load_seed'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /Users/chance/code/rails/nokr/db/seeds.rb:10:in `&lt;top (required)&gt;'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:520:in `load_seed'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/activerecord-3.2.3/lib/active_record/railties/databases.rake:309:in `block (2 levels) in &lt;top (required)&gt;'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
  /Users/chance/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `&lt;top (required)&gt;'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/bin/rake:19:in `load'
  /Users/chance/code/rails/nokr/activesupport/ruby/1.9.1/bin/rake:19:in `&lt;main&gt;'
  Tasks: TOP =&gt; db:seed
  </code></pre>
  
  <hr>
  
  <p><strong>migrations</strong></p>
  
  <pre><code>up     20120409194703  Create refinerycms authentication schema.refinery authentication
  up     20120409194704  Create refinerycms images schema.refinery images
  up     20120409194705  Create refinerycms resources schema.refinery resources
  up     20120409194706  Create refinerycms pages schema.refinery pages
  up     20120409194707  Create seo meta.seo meta engine
  </code></pre>
  
  <hr>
  
  <p><strong>gemfile</strong></p>
  
  <pre><code>require 'rbconfig'
  HOST_OS = Config::CONFIG['host_os']
  source 'http://rubygems.org'
  group :assets do
    gem 'sass-rails'
    gem 'coffee-rails'
    gem 'uglifier'
    gem 'compass'
  end
  gem 'rack'
  gem 'rails', "~&gt; 3.2"
  group :development, :test do
    gem 'sqlite3'
  end
  gem "geocoder"
  gem "geonames"
  gem "devise", "~&gt; 2.0"
  gem "geocoder"
  gem "geonames"
  gem "paperclip", "~&gt; 2.4"
  gem 'transloadit-rails'
  gem 'uuidtools' 
  gem "friendly_id", "~&gt; 4.0.0.beta14"
  gem "squeel"
  gem "pg"
  gem "cancan"
  gem 'kaminari'
  #gem 'cantango'
  gem "formtastic"
  gem 'will_paginate'
  gem "nested_form", :git =&gt; "git://github.com/ryanb/nested_form.git"
  gem 'tire', :git =&gt; 'https://github.com/karmi/tire'
  gem 'multi_json'
  gem 'active_scaffold'
  gem "meta_search"
  gem 'newrelic_rpm'
  gem 'paper_trail'
  gem 'jquery-rails'
  gem 'activeadmin', :git =&gt; "git://github.com/gregbell/active_admin.git"
  gem 'refinerycms', '~&gt; 2.0.0'
  gem 'refinerycms-i18n',   '~&gt; 2.0.0'
  #  gem 'refinerycms-blog', '~&gt; 2.0.0'
  #  gem 'refinerycms-inquiries', '~&gt; 2.0.0'
  #  gem 'refinerycms-search', '~&gt; 2.0.0'
  #  gem 'refinerycms-page-images', '~&gt; 2.0.0'
  if HOST_OS =~ /linux/i
    gem 'therubyracer', '&gt;= 0.8.2'
  end
  gem "haml", "&gt;= 3.1.2"
  
  group :development do
    gem "haml-rails", "&gt;= 0.3.4"
    gem "rspec-rails", "&gt;= 2.6.1"
    gem "guard", "&gt;= 0.6.2"
    gem "rails-footnotes", "&gt;= 3.7"
    gem 'rb-fsevent'
    gem 'growl'
    gem "guard-bundler", "&gt;= 0.1.3"
    gem "guard-rails", "&gt;= 0.0.3"
    gem "guard-livereload", "&gt;= 0.3.0"
    gem "guard-rspec", "&gt;= 0.4.3"
    gem "guard-cucumber", "&gt;= 0.6.1"
  end
  
  group :test do
    gem "factory_girl_rails", "&gt;= 1.2.0"
    gem "cucumber-rails", "&gt;= 1.1.1"
    gem "capybara", "&gt;= 1.1.1"
    gem "database_cleaner", "&gt;= 0.6.7"
    gem "launchy", "&gt;= 2.0.5"
    gem "rspec-rails", "&gt;= 2.6.1"
    gem "guard", "&gt;= 0.6.2"
    gem 'rb-fsevent'
    gem 'growl'
    gem "guard-bundler", "&gt;= 0.1.3"
    gem "guard-rspec", "&gt;= 0.4.3"
    gem "guard-cucumber", "&gt;= 0.6.1"
  end
  </code></pre>
  
  <hr>
  
  <p><strong>partial schema</strong></p>
  
  <pre><code> create_table "refinery_images", :force =&gt; true do |t|
      t.string   "image_mime_type"
      t.string   "image_name"
      t.integer  "image_size"
      t.integer  "image_width"
      t.integer  "image_height"
      t.string   "image_uid"
      t.string   "image_ext"
      t.datetime "created_at",      :null =&gt; false
      t.datetime "updated_at",      :null =&gt; false
    end
  
    create_table "refinery_page_part_translations", :force =&gt; true do |t|
      t.integer  "refinery_page_part_id"
      t.string   "locale"
      t.text     "body"
      t.datetime "created_at",            :null =&gt; false
      t.datetime "updated_at",            :null =&gt; false
    end
  
    add_index "refinery_page_part_translations", ["locale"], :name =&gt; "index_refinery_page_part_translations_on_locale"
    add_index "refinery_page_part_translations", ["refinery_page_part_id"], :name =&gt; "index_f9716c4215584edbca2557e32706a5ae084a15ef"
  
    create_table "refinery_page_parts", :force =&gt; true do |t|
      t.integer  "refinery_page_id"
      t.string   "title"
      t.text     "body"
      t.integer  "position"
      t.datetime "created_at",       :null =&gt; false
      t.datetime "updated_at",       :null =&gt; false
    end
  
    add_index "refinery_page_parts", ["id"], :name =&gt; "index_refinery_page_parts_on_id"
    add_index "refinery_page_parts", ["refinery_page_id"], :name =&gt; "index_refinery_page_parts_on_refinery_page_id"
  
    create_table "refinery_page_translations", :force =&gt; true do |t|
      t.integer  "refinery_page_id"
      t.string   "locale"
      t.string   "title"
      t.string   "custom_slug"
      t.string   "menu_title"
      t.string   "slug"
      t.datetime "created_at",       :null =&gt; false
      t.datetime "updated_at",       :null =&gt; false
    end
  
    add_index "refinery_page_translations", ["locale"], :name =&gt; "index_refinery_page_translations_on_locale"
    add_index "refinery_page_translations", ["refinery_page_id"], :name =&gt; "index_d079468f88bff1c6ea81573a0d019ba8bf5c2902"
  
    create_table "refinery_pages", :force =&gt; true do |t|
      t.integer  "parent_id"
      t.string   "path"
      t.string   "slug"
      t.boolean  "show_in_menu",        :default =&gt; true
      t.string   "link_url"
      t.string   "menu_match"
      t.boolean  "deletable",           :default =&gt; true
      t.boolean  "draft",               :default =&gt; false
      t.boolean  "skip_to_first_child", :default =&gt; false
      t.integer  "lft"
      t.integer  "rgt"
      t.integer  "depth"
      t.string   "view_template"
      t.string   "layout_template"
      t.datetime "created_at",                             :null =&gt; false
      t.datetime "updated_at",                             :null =&gt; false
    end
  
    add_index "refinery_pages", ["depth"], :name =&gt; "index_refinery_pages_on_depth"
    add_index "refinery_pages", ["id"], :name =&gt; "index_refinery_pages_on_id"
    add_index "refinery_pages", ["lft"], :name =&gt; "index_refinery_pages_on_lft"
    add_index "refinery_pages", ["parent_id"], :name =&gt; "index_refinery_pages_on_parent_id"
    add_index "refinery_pages", ["rgt"], :name =&gt; "index_refinery_pages_on_rgt"
  
    create_table "refinery_resources", :force =&gt; true do |t|
      t.string   "file_mime_type"
      t.string   "file_name"
      t.integer  "file_size"
      t.string   "file_uid"
      t.string   "file_ext"
      t.datetime "created_at",     :null =&gt; false
      t.datetime "updated_at",     :null =&gt; false
    end
  
    create_table "refinery_roles", :force =&gt; true do |t|
      t.string "title"
    end
  
    create_table "refinery_roles_users", :id =&gt; false, :force =&gt; true do |t|
      t.integer "user_id"
      t.integer "role_id"
    end
  
    add_index "refinery_roles_users", ["role_id", "user_id"], :name =&gt; "index_refinery_roles_users_on_role_id_and_user_id"
    add_index "refinery_roles_users", ["user_id", "role_id"], :name =&gt; "index_refinery_roles_users_on_user_id_and_role_id"
  
    create_table "refinery_user_plugins", :force =&gt; true do |t|
      t.integer "user_id"
      t.string  "name"
      t.integer "position"
    end
  
    add_index "refinery_user_plugins", ["name"], :name =&gt; "index_refinery_user_plugins_on_name"
    add_index "refinery_user_plugins", ["user_id", "name"], :name =&gt; "index_refinery_user_plugins_on_user_id_and_name", :unique =&gt; true
  
    create_table "refinery_users", :force =&gt; true do |t|
      t.string   "username",               :null =&gt; false
      t.string   "email",                  :null =&gt; false
      t.string   "encrypted_password",     :null =&gt; false
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string   "current_sign_in_ip"
      t.string   "last_sign_in_ip"
      t.integer  "sign_in_count"
      t.datetime "remember_created_at"
      t.string   "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "created_at",             :null =&gt; false
      t.datetime "updated_at",             :null =&gt; false
    end
  
    add_index "refinery_users", ["id"], :name =&gt; "index_refinery_users_on_id"
  
    create_table "seo_meta", :force =&gt; true do |t|
      t.integer  "seo_meta_id"
      t.string   "seo_meta_type"
      t.string   "browser_title"
      t.string   "meta_keywords"
      t.text     "meta_description"
      t.datetime "created_at",       :null =&gt; false
      t.datetime "updated_at",       :null =&gt; false
    end
  
    add_index "seo_meta", ["id"], :name =&gt; "index_seo_meta_on_id"
    add_index "seo_meta", ["seo_meta_id", "seo_meta_type"], :name =&gt; "index_seo_meta_on_seo_meta_id_and_seo_meta_type"
  
    create_table "user_addresses", :force =&gt; true do |t|
      t.integer  "address_id"
      t.integer  "user_id"
      t.datetime "created_at", :null =&gt; false
      t.datetime "updated_at", :null =&gt; false
    end
  </code></pre>
  
  <hr>
  
  <p>I asked this question on the Refinery CMS Google Groups earlier if you prefer to <a href="http://groups.google.com/group/refinery-cms/browse_thread/thread/adf1c9a1955e5ddf" rel="nofollow">answer there</a>.</p>