我正在向我的数据库中添加一个“问题”表......当我迁移它时......一切似乎都很好。但是当我进入rails控制台时......它告诉我'NameError:未初始化的常量问题'
我错过了什么?这是我的迁移输出、迁移文件数据和 rails 控制台错误。
我是 Rails 的初学者,所以请原谅我的菜鸟。
所以我在我的 rake db:migrate... 之后得到了这个
Zach:FundAnEd zach$ rake db:migrate
== DropQuestionTable: migrating ==============================================
-- drop_table(:questions)
-> 0.0490s
== DropQuestionTable: migrated (0.0492s) =====================================
== CreateQuestions: migrating ================================================
-- create_table(:questions)
-> 0.0161s
-- add_index(:questions, :scholarship_id)
-> 0.0254s
== CreateQuestions: migrated (0.0417s) =======================================
这是我的迁移文件内容...
class CreateQuestions < ActiveRecord::Migration
def change
create_table :questions do |t|
t.string :question_type
t.references :scholarship
t.string :question_title
t.timestamps
end
add_index :questions, :scholarship_id
end
end
这是我得到的错误....
NameError: uninitialized constant Question
from (irb):1
from /Users/zach/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /Users/zach/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /Users/zach/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我究竟做错了什么?我错过了什么?