我向數據庫中添加'questions'表...當我遷移它時...一切似乎都很好。 但是當我進入rails控制檯...它告訴我'NameError:未初始化的常量問題'NameError:在軌道控制檯中未初始化的常量
我在想什麼?這是我的遷移輸出,遷移文件數據和rails控制檯錯誤。
我是Rails的初學者,所以請原諒我的noobness。
所以我得到這個我耙分貝後:遷移...
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>'
我在做什麼錯?我錯過了什麼?
你有問題模型?如果是,請包含其代碼。 – Matzi
你在得到錯誤之前做了什麼? – Thanh