would not need the new table, just change the type could be used for the new model
如果model的相似度高例如 comment , 一個網站裡面很多都可以需要comment
就可以用這個
[forum model]
has_many :comments, :as => :record
[record model]
has_many :comments, :as => :record
[comment model]
belongs_to :record, :polymorphic => true
[comments table]
create_table "comments", :force => true do |t|
t.text "content"
t.integer "record_id", :limit => 11, :null => false
t.string "record_type"
end
沒有留言:
張貼留言