-1

我刚刚重新安装了我的 Ubuntu,所以我安装了 Ribu 和 Rails。一切进展顺利,但是当我尝试制作模型(数据库表)时,出现了几个错误。这是没有痕迹的错误:

cdr@ubuntu:~/pro$ rake db:migrate
==  CreateMonsters: migrating =================================================
-- create_table(:monsters)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `straing' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x000000023cae90>
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:4:in `block in change'
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

这是有迹可循的:

cdr@ubuntu:~/pro$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
==  CreateMonsters: migrating =================================================
-- create_table(:monsters)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `straing' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000003f4c3d0>
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:4:in `block in change'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in `block in method_missing'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `block in say_with_time'
/usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `say_with_time'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in `method_missing'
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:3:in `change'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:407:in `block (2 levels) in migrate'
/usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:407:in `block in migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:389:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:528:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `call'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:208:in `transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `ddl_transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:719:in `block in migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:700:in `each'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:700:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `up'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:551:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

这是迁移:

class CreateMonsters < ActiveRecord::Migration
  def change
    create_table :monsters do |t|
      t.straing :name
      t.text :description

      t.timestamps
    end
  end
end
4

1 回答 1

1

t.straing? 那应该是t.string

您发布的错误(下面的片段)

An error has occurred, this and all later migrations canceled:

undefined method `straing'

正在为你指出错误的方向

于 2012-12-01T20:23:36.993 回答