將實體推送到它的父集合會導致集合被加載嗎?Rails關聯推(collection <<)
例如爲:
Parent.childs << a_child
是在parent.childs 「陣列」 現在裝了所有孩子的,或只是 「a_child」?即將SQL「select * from childs where parent_id =?」語句將在添加到集合之前執行?
編輯:
http://apidock.com/rails/v3.2.3/ActiveRecord/Associations/CollectionAssociation/concat_records似乎稱之爲 「add_target」 以前叫 「insert_record」 它增加了實體的@target陣列...
你可以在你的Rails控制檯嘗試了這一點('軌console',或'軌C'的簡稱),看看SQL獲得什麼產生。 – MrDanA
順便說一下,它是'''兒童''' – Zepplock