2012-07-11 11 views
5

Estoy siguiendo el RoR Getting Started tutorial. Después de haber creado publicaciones, ahora estoy agregando el segundo modelo para crear comentarios. Sin embargo, cuando intento rastrillo db:migrate me sale esto:RoR Guía de introducción: Rake db: migrar el método no definido 'referencia'

** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Invoke db:load_config (first_time) 
** Invoke rails_env (first_time) 
** Execute rails_env 
** Execute db:load_config 
** Execute db:migrate 
== CreateComments: migrating ================================================= 
-- create_table(:comments) 
rake aborted! 
An error has occurred, this and all later migrations canceled: 

undefined method `reference' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x1084a24d8> 
/Users/Fryed/rails/blog/db/migrate/20120710225337_create_comments.rb:6:in `change' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:466:in `send' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:466:in `method_missing' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `say_with_time' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `say_with_time' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:458:in `method_missing' 
/Users/Fryed/rails/blog/db/migrate/20120710225337_create_comments.rb:3:in `change' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `migrate' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:389:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:528:in `__send__' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:528:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:720:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `call' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `ddl_transaction' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `ddl_transaction' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:719:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `each' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:570:in `up' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:551:in `migrate' 
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/railties/databases.rake:153 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain' 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/bin/rake:33 
/usr/bin/rake:23:in `load' 
/usr/bin/rake:23 
Tasks: TOP => db:migrate 

estoy corriendo:

Rake 0.9.2.2. de Ruby 1.8.7 Rails 3.2.6

Respuesta

18

migraciones con referencias usan el helper references, es probable que sólo se olvidó de poner el s al final.

Encuentra la migración infractor db/migrate/20120710225337_create_comments.rb y el cambio de reference a references

+0

Brilliant! Eso funciona, gracias. :) –

+0

¡Y todavía funciona 3 años más tarde! jaja ... – rtfminc

+0

todavía funciona 4 años después :-) – Alagu

Cuestiones relacionadas