在 SqlLite3 中创建新表时遇到问题
我使用脚手架生成器创建了此迁移:
class CreateTimes < ActiveRecord::Migration
def self.up
create_table :times do |t|
t.integer :regsite
t.integer :user_id
t.timestamp :added
t.integer :time
t.text :note
t.timestamps
end
end
def self.down
drop_table :times
end
end
文件名称为20091011203652_create_times.rb
尝试迁移时出现此错误:
>rake db:migrate (in C:/...) rake aborted! uninitialized constant ActiveRecord C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2359:in `raw_load_rakefile' (See full trace by running task with --trace)
我昨天开始从 PHP 适应 RoR,很抱歉,如果这是一个显而易见的答案,但已经尝试了我所知道的一切,但没有解决问题。
最佳答案
您不能次调用您的表,因为这需要一个名为Time
的模型类,它是一个内置的Ruby类。我敢打赌这就是问题所在。尝试将其更改为其他内容,看看是否有帮助。
关于ruby-on-rails - 迁移时 "uninitialized constant ActiveRecord",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1551733/