0

したがって、次のように db->migrate フォルダーに 001_create_users.rb という名前の手動ファイルを作成しました。

class CreateUsers < ActiveRecord::Base
  def self.up
    create_table :users do |t|
      t.string :name
      t.string :email
      t.string :password
      t.string :bio

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end

次に、 :bundle exec rake db:migrateコマンドを実行すると、次のエラーが発生します。

レーキが中止されました! エラーが発生しました。これ以降の移行はすべてキャンセルされました:

テーブル「create_users」が見つかりませんでした

エラーは詳細なので、ターミナルウィンドウからコピーアンドペーストするだけですが、最初の部分はエラーの先頭です

レーキが中止されました! エラーが発生しました。これ以降の移行はすべてキャンセルされました:

テーブル 'create_users' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:472:table_structure' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in列が見つかりませんでした/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/schema_cache.rb:12:in block in initialize' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:228:in yield' /Users/JonyIve/.rvm /gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:228:in default' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:228:in columns' /Users/JonyIve/.rvm/gems/ruby-1.9.3- p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:243:in column_defaults' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/base.rb:482:in initialize' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2 .11/lib/active_record/migration.rb:538:in new' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:538:in load_migration' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:533:in migration' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in migrate' /Users/JonyIve/.rvm /gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in block (2 levels) in migrate' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in call' /Users/JonyIve/.rvm/gems/ruby-1.9.3- p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in block in ddl_transaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2 .11/lib/active_record/transactions.rb:208:in transaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in ddl_transaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration. rb:719:で block in migrate' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in each' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in migrate' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in up' /Users/JonyIve/.rvm /gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:551:in migrate' /Users/JonyIve/Documents/HisFirstService/Rakefile:19:in ブロック (2 レベル) in ' /Users/JonyIve/.rvm/gems/ruby -1.9.3-p362@railsbabak/bin/ruby_noexec_wrapper:14:in eval' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/bin/ruby_noexec_wrapper:14:in ' タスク: TOP => db:migrate ( --trace を指定してタスクを実行すると、完全なトレースが表示されます)

また、「どの宝石」と言うと、次のようになります。

which gem
/Users/JonyIve/.rvm/rubies/ruby-1.9.3-p362/bin/gem
4

1 に答える 1

2

ActiveRecord::Baseあるべき時期から継承していますActiveRecord::Migration

class CreateProjects < ActiveRecord::Migration
  def change
    create_table :projects do |t|
      t.text :title
      t.text :description
      t.text :slug

      t.timestamps
    end
  end
end
于 2013-01-30T20:43:50.543 に答える