I have migration 20150930051523_create_objects.rb:
class CreateObjects < ActiveRecord::Migration
def change
create_table :objects do |t|
t.text :name
t.timestamps null: false
end
Object.create :name => "A"
Object.create :name => "B"
Object.create :name => "C"
end
end
$ rake:db migrate --trace cause output: ** Invoke db:migrate (first_time) ** Invoke db:environment (first_time) ** Execute db:environment ** Invoke db:load_config (first_time) ** Execute db:load_config ** Execute db:migrate == 20150930051523 CreateObjects: migrating ==================================== -- create_table(:objects) -> 0.0010s rake aborted! StandardError: An error has occurred, this and all later migrations canceled: uninitialized constant CreateObjects::Object/db/migrate/20150930051523_create_objects.rb:8:in `change' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:605:in `exec_migration' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:589:in `block (2 levels) in migrate' /usr/lib/ruby/2.1.0/benchmark.rb:279:in `measure' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:588:in `block in migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:587:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:765:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `block in ddl_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/transactions.rb:220:in `transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `ddl_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:994:in `execute_migration_in_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:956:in `block in migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `each' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in ' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain' /usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run' /var/lib/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `' /usr/local/bin/rake:23:in `load' /usr/local/bin/rake:23:in `' NameError: uninitialized constant CreateObjects::Object/db/migrate/20150930051523_create_barbers.rb:8:in `change' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:605:in `exec_migration' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:589:in `block (2 levels) in migrate' /usr/lib/ruby/2.1.0/benchmark.rb:279:in `measure' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:588:in `block in migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:587:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:765:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `block in ddl_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/transactions.rb:220:in `transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:1041:in `ddl_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:994:in `execute_migration_in_transaction' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:956:in `block in migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `each' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:952:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate' /var/lib/gems/2.1.0/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in ' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain' /usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling' /var/lib/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run' /var/lib/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `' /usr/local/bin/rake:23:in `load' /usr/local/bin/rake:23:in `' Tasks: TOP => db:migrate
Error emerging at Object.create... stage, what is wrong?
The problem was solved by set up pg gem, which pull bundle of another gems and packs (particularly postgresql-server-dev-all). After installing it, the command rake db:migrate works fine and completely.