我有兩個型號 '教程' 和 'Tutorialcategory'PG ::錯誤:錯誤:列tutorials.tutorialcategory_id不存在
class Tutorialcategory < ActiveRecord::Base
has_many :tutorials
class Tutorial < ActiveRecord::Base
belongs_to :tutorialcategory
教程與多個類別,如HTML相關,rubyonrails其中HTML和Ruby on導軌tutorialcategories
以下是遷移
class CreateTutorials < ActiveRecord::Migration
def change
create_table :tutorials,force: true do |t|
t.string :title
t.text :body
t.integer :rating
t.string :videoid
t.belongs_to :tutorialcategory
t.timestamps
end
end
end
class CreateTutorialcategories < ActiveRecord::Migration
def change
create_table :tutorialcategories do |t|
t.string :title
t.timestamps null:false
end
end
end
所有教程都索引頁上正常上市,但是當我看到分類頁面給它ŝ我下面的錯誤
PG::Error: ERROR: column tutorials.tutorialcategory_id does not exist
您是否記得在創建遷移後運行'rake db:migrate'? –
是的,我做到了,我可以添加教程。 –
@Vikram你勾選了[這個](http://stackoverflow.com/questions/5450930/heroku-postgres-error-pgerror-error-relation-organizations-does-not-exist)thread?希望這會是一些幫助。 – Lahiru