Ruby on rails Rake迁移找不到表
因此,我在db->migrate文件夹中创建了一个手动文件名001_create_users.rb,如下所示:Ruby on rails Rake迁移找不到表,ruby-on-rails,rake,rails-migrations,Ruby On Rails,Rake,Rails Migrations,因此,我在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
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
您是从
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
class CreateProject
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