Imagine the following application: # config/environment.rb: ... config.active_record.observers = :user_observer ... # app/models/user.rb: class User < ActiveRecord::Base MY_CONST = Other::ITS_CONST end # app/models/other.rb: class Other < ActiveRecord::Base ITS_CONST = 1 end # app/models/user_observer.rb: class UserObserver < ActiveRecord::Observer end ---- This works fine as long as the "users" and "others" tables are already created. However, if they''re not, you can''t actually run the migration to create those tables, because rails dies during initialization: /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:135:in `log'':ActiveRecord::StatementInvalid: RuntimeError: ERROR C42P01 Mrelation "users" does not exist Fnamespace.c L200 RRangeVarGetRelid: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = ''users''::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum This is on Cygwin with Postgres running edge rails, but I get a similar result on a Mac with MySql (it uses "SHOW FIELDS FROM" to get the column names instead). The full stack is below. Anyone have any suggestions? RuntimeError: ERROR C42P01 Mrelation "users" does not exist Fnamespace.c L200 RRangeVarGetRelid: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = ''users''::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:135:in `log'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:150:in `query'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:537:in `column_definitions'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:231:in `columns'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/base.rb:842:in `columns'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/base.rb:916:in `inspect'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/symbol.rb:10:in `__send__'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/symbol.rb:10:in `to_proc'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:427:in `collect'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:427:in `log_call'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:222:in `load_missing_constant'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:468:in `const_missing'' /cygdrive/c/dev/src/tmp/test_observers/app/models/user.rb:2 /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:203:in `load_file'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in `new_constants_in'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:202:in `load_file'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:94:in `require_or_load'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:248:in `load_missing_constant'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:464:in `const_missing'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:257:in `constantize'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/observer.rb:144:in `observed_class'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/observer.rb:170:in `observed_classes'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/observer.rb:153:in `initialize'' /usr/lib/ruby/1.8/singleton.rb:95:in `new'' /usr/lib/ruby/1.8/singleton.rb:95:in `instance'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/observer.rb:38:in `instantiate_observers'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/observer.rb:36:in `each'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/activerecord/lib/active_record/observer.rb:36:in `instantiate_observers'' /cygdrive/c/dev/src/tmp/test_observers/config/../vendor/rails/railties/lib/initializer.rb:210:in `load_observers'' /cygdrive/c/dev/src/tmp/test_observers/config/../vendor/rails/railties/lib/initializer.rb:112:in `process'' /cygdrive/c/dev/src/tmp/test_observers/config/../vendor/rails/railties/lib/initializer.rb:49:in `send'' /cygdrive/c/dev/src/tmp/test_observers/config/../vendor/rails/railties/lib/initializer.rb:49:in `run'' /cygdrive/c/dev/src/tmp/test_observers/config/environment.rb:13 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /cygdrive/c/dev/src/tmp/test_observers/vendor/rails/railties/lib/tasks/misc.rake:3 /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:369:in `invoke_prerequisites'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `send'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:368:in `invoke_prerequisites'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:361:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load'' /usr/bin/rake:16 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---