0

我已经运行了 rake db:migrate,schema.rb 看起来不错,当我在 rails dbconsole 中运行 .tables 时,我可以看到我正在寻找的表。我之前确实进行了回滚,但后来我最终运行了 rake db:reset。还有其他想法吗?

导轨 4,红宝石 1.9.3

架构.rb:

`ActiveRecord::Schema.define(version: 20130501043644) do

  create_table "playlists", force: true do |t|
    t.string   "name"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "songs", force: true do |t|
    t.string   "name"
    t.string   "artist"
    t.string   "soundcloud"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "songs_playlists", id: false, force: true do |t|
    t.integer "song_id"
    t.integer "playlist_id"
  end

end`

从运行 rake db:seed --trace 跟踪

    `Could not find table 'playlists_songs'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:509:in `table_structure'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:396:in `columns'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:114:in `block in prepare_default_proc'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:56:in `yield'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:56:in `default'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:56:in `columns'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:118:in `block in prepare_default_proc'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:67:in `yield'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:67:in `default'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/connection_adapters/schema_cache.rb:67:in `columns_hash'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:25:in `column_for'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:37:in `bind'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:73:in `block in add_constraints'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:44:in `each'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:44:in `each_with_index'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:44:in `add_constraints'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association_scope.rb:19:in `scope'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association.rb:100:in `association_scope'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/association.rb:84:in `scope'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/collection_association.rb:382:in `scope'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/collection_proxy.rb:37:in `initialize'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/relation/delegation.rb:78:in `new'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/collection_association.rb:37:in `reader'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/associations/builder/association.rb:70:in `songs'
    /Users/paulruescher/Desktop/Dropbox/gtfomp/db/seeds.rb:11:in `<top (required)>'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activesupport/lib/active_support/dependencies.rb:222:in `load'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activesupport/lib/active_support/dependencies.rb:222:in `block in load'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activesupport/lib/active_support/dependencies.rb:213:in `load_dependency'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activesupport/lib/active_support/dependencies.rb:222:in `load'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/railties/lib/rails/engine.rb:540:in `load_seed'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/tasks/database_tasks.rb:161:in `load_seed'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bundler/gems/rails-78db16d440c6/activerecord/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)>'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
    /Users/paulruescher/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
    /Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `<main>'

Rails 3.2.12 rake db:seed --trace

SQLite3::SQLException: no such table: playlists_songs: INSERT INTO "playlists_songs" ("song_id", "playlist_id") VALUES (5, 5)
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `initialize'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `new'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `prepare'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:246:in `block in exec_query'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:242:in `exec_query'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/has_and_belongs_to_many_association.rb:29:in `insert_record'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:496:in `block (2 levels) in concat_records'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:344:in `add_to_target'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:495:in `block in concat_records'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:493:in `each'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:493:in `concat_records'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:134:in `block in concat'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:149:in `block in transaction'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transaction'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:148:in `transaction'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_association.rb:134:in `concat'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/associations/collection_proxy.rb:116:in `<<'
/Users/paulruescher/Desktop/Dropbox/fomp/db/seeds.rb:11:in `<top (required)>'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/engine.rb:520:in `load_seed'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:333:in `block (2 levels) in <top (required)>'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/Users/paulruescher/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
/Users/paulruescher/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `<main>'`
4

1 回答 1

2

在您的架构中,您有song_playlists但在您的模型中,您正在寻找playlists_songs

于 2013-05-01T08:06:22.087 回答