したがって、次のように 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:inblock 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:indefault' /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:incolumn_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:innew' /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:inmigration' /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:inblock (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:inblock 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:intransaction' /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:inmigrate' /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:inmigrate' /Users/JonyIve/Documents/HisFirstService/Rakefile:19:in
ブロック (2 レベル) in ' /Users/JonyIve/.rvm/gems/ruby -1.9.3-p362@railsbabak/bin/ruby_noexec_wrapper:14:ineval' /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