teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

画像アップロード使用

2021/02/06 23:46

投稿

osugi86
osugi86

スコア3

title CHANGED
File without changes
body CHANGED
@@ -104,4 +104,6 @@
104
104
  ![イメージ説明](f6d2980af8f282b367a6906537e1a1b6.png)
105
105
  上の画像のように@detailの情報しか反映されません。
106
106
  @mainからも反映されるようにしたいです。
107
- 何かいい方法ないでしょうか?
107
+ 何かいい方法ないでしょうか?
108
+ --------追記----------
109
+ Activestorageを使用しているのですが保存されている画像についても反映されません

1

モデルの追加

2021/02/06 23:46

投稿

osugi86
osugi86

スコア3

title CHANGED
File without changes
body CHANGED
@@ -73,6 +73,34 @@
73
73
 
74
74
  end
75
75
  ```
76
+ main
77
+ ```Ruby
78
+ class CreateMains < ActiveRecord::Migration[6.0]
79
+ def change
80
+ create_table :mains do |t|
81
+ t.string :name, null: false
82
+ t.text :info, null: false
83
+
84
+ t.references :user, null: false, foreign_key: true
85
+ end
86
+ end
87
+ end
88
+ ```
89
+ detail
90
+ ```Ruby
91
+ class CreateDetails < ActiveRecord::Migration[6.0]
92
+ def change
93
+ create_table :details do |t|
94
+
95
+ t.integer :category_id, null: false
96
+ t.integer :country_id, null: false
97
+
98
+ t.references :main, null: false, foreign_key: true
99
+ end
100
+ end
101
+ end
102
+
103
+ ```
76
104
  ![イメージ説明](f6d2980af8f282b367a6906537e1a1b6.png)
77
105
  上の画像のように@detailの情報しか反映されません。
78
106
  @mainからも反映されるようにしたいです。