From 4bfa1a8755c7891c643e884513f96042d8433009 Mon Sep 17 00:00:00 2001 From: kinseyost Date: Wed, 28 Sep 2016 07:37:57 -0700 Subject: [PATCH] How to associate tables in rich many-to-many. --- Tutorial_Docs/Associations.MD | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Tutorial_Docs/Associations.MD b/Tutorial_Docs/Associations.MD index caa453e..3de1670 100644 --- a/Tutorial_Docs/Associations.MD +++ b/Tutorial_Docs/Associations.MD @@ -82,3 +82,26 @@ edit = SectionEdit.new ``` edit.summary = "Edited some content" ``` + +``` +me = AdminUser.find(1) +``` + +``` +section = Section.find(1) +``` + +``` +section.section_edits << edit +``` + +``` +me.section_edits << edit +``` + +### Reloading from DB +Sometimes your, especially if you use `edit.section = section` emphasis on the `=` operator, the models in rails console might get out of sync. +You can tell rails console to refresh from the db by using +``` +edit.editor(true) +```