Week5 Day3 Assigement-Forum 作業筆記2

參考資料:ActiveRecord — 基本操作與關聯設計

Category 多對多to Article

rails g model category name:string
rails g model article_categoryship article_id:integer category_id:integer

rake db:migrate

class Article < ActiveRecord::Base
validates_presence_of :topic
has_many :article_categoryships
has_many :categoeies, :through => :article_categoryships
end
class Category < ActiveRecord::Base
has_many :article_categoryships
has_many :articles, :through => :article_categoryships
end
class ArticleCategoryship < ActiveRecord::Base
belongs_to :article
belongs_to :category
end

這禮拜已經發生兩次table莫名消失,消極解決方案就是

rake db:drop --> db:create --> db:migrate

然後一切就恢復正常,無解,國外也有許多table消失的例子

真的,沒空去追根究柢這個項目,六日沒看書真的進度很落後。

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.