質問編集履歴
2
モデルについて追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -23,10 +23,31 @@
|
|
23
23
|
params.require(:article).permit(:title, :description, :main_image,article_chapter_blocks_attributes: [:id, :title, :_destroy, {article_chapter_text_parts_attributes: [:id, :title, :description, :_destroy]}])
|
24
24
|
end
|
25
25
|
```
|
26
|
-
モデル
|
26
|
+
モデル
|
27
|
+
```ruby
|
27
|
-
|
28
|
+
class ArticleChapterTextPart < ActiveRecord::Base
|
29
|
+
belongs_to :article_chapter_block
|
30
|
+
belongs_to :article
|
31
|
+
end
|
28
32
|
|
33
|
+
class Article < ActiveRecord::Base
|
34
|
+
has_many :article_chapter_blocks
|
29
|
-
|
35
|
+
has_many :article_chapter_text_parts
|
30
36
|
|
37
|
+
accepts_nested_attributes_for :article_chapter_blocks, allow_destroy: true
|
31
38
|
|
39
|
+
#carrierwave
|
40
|
+
mount_uploader :main_image, AriticleImageUploader
|
41
|
+
end
|
42
|
+
|
43
|
+
class ArticleChapterBlock < ActiveRecord::Base
|
44
|
+
belongs_to :article
|
45
|
+
|
46
|
+
has_many :article_chapter_text_parts
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
今回は、Nested Formのgemを使ってformから更新しようとしてます。
|
51
|
+
|
52
|
+
|
32
53
|
何時間も悩んでもできなかったので、誰か助けてください。お願いします。
|
1
タグの追加
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|