質問編集履歴

2

モデルについて追記

2017/05/18 13:45

投稿

benkyouchuu
benkyouchuu

スコア26

test CHANGED
File without changes
test CHANGED
@@ -48,13 +48,55 @@
48
48
 
49
49
  ```
50
50
 
51
- モデルの関係
51
+ モデル
52
52
 
53
+ ```ruby
54
+
53
- article 1- 多 article_chapter_block 1-多 article_chapter_text_parts
55
+ class ArticleChapterTextPart < ActiveRecord::Base
56
+
57
+ belongs_to :article_chapter_block
58
+
59
+ belongs_to :article
60
+
61
+ end
54
62
 
55
63
 
56
64
 
65
+ class Article < ActiveRecord::Base
66
+
67
+ has_many :article_chapter_blocks
68
+
57
- article 1- article_chapter_text_parts
69
+ has_many :article_chapter_text_parts
70
+
71
+
72
+
73
+ accepts_nested_attributes_for :article_chapter_blocks, allow_destroy: true
74
+
75
+
76
+
77
+ #carrierwave
78
+
79
+ mount_uploader :main_image, AriticleImageUploader
80
+
81
+ end
82
+
83
+
84
+
85
+ class ArticleChapterBlock < ActiveRecord::Base
86
+
87
+ belongs_to :article
88
+
89
+
90
+
91
+ has_many :article_chapter_text_parts
92
+
93
+ end
94
+
95
+ ```
96
+
97
+
98
+
99
+ 今回は、Nested Formのgemを使ってformから更新しようとしてます。
58
100
 
59
101
 
60
102
 

1

タグの追加

2017/05/18 13:45

投稿

benkyouchuu
benkyouchuu

スコア26

test CHANGED
File without changes
test CHANGED
File without changes