質問編集履歴

3

内容の変更

2021/02/10 12:08

投稿

Fumi_Kazu5
Fumi_Kazu5

スコア1

test CHANGED
File without changes
test CHANGED
@@ -82,6 +82,12 @@
82
82
 
83
83
 
84
84
 
85
+
86
+
87
+
88
+
89
+
90
+
85
91
  説明が足りなくてすみません。追加記入です。
86
92
 
87
93
  rails db:migrate:statusの結果
@@ -133,3 +139,31 @@
133
139
  end
134
140
 
135
141
  end
142
+
143
+
144
+
145
+
146
+
147
+ データベース
148
+
149
+ class CreateShoppings < ActiveRecord::Migration[6.0]
150
+
151
+ def change
152
+
153
+ create_table :shoppings do |t|
154
+
155
+ t.string :product_name, null: false
156
+
157
+ t.integer :price, null: false
158
+
159
+ #t.references :owner, foreign_key: true
160
+
161
+
162
+
163
+ t.timestamps
164
+
165
+ end
166
+
167
+ end
168
+
169
+ end

2

内容の変更

2021/02/10 12:08

投稿

Fumi_Kazu5
Fumi_Kazu5

スコア1

test CHANGED
File without changes
test CHANGED
@@ -75,3 +75,61 @@
75
75
  Tasks: TOP => db:migrate
76
76
 
77
77
  (See full trace by running task with --trace)
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+ 説明が足りなくてすみません。追加記入です。
86
+
87
+ rails db:migrate:statusの結果
88
+
89
+
90
+
91
+ database: tomori_app_development
92
+
93
+
94
+
95
+ Status Migration ID Migration Name
96
+
97
+ --------------------------------------------------
98
+
99
+ up 20210126060600 Devise create users
100
+
101
+ up 20210126062512 Create active storage tablesactive storage
102
+
103
+ up 20210129112855 Create shoppings
104
+
105
+ up 20210131072013 Create orders
106
+
107
+ up 20210131143313 Devise create owners
108
+
109
+
110
+
111
+ モデルの記入内容
112
+
113
+ class Shopping < ApplicationRecord
114
+
115
+ belongs_to :owner, optional: true, foreign_key: :owner_id
116
+
117
+ has_one :order
118
+
119
+ has_one_attached :image
120
+
121
+ # extend ActiveHash::Associations::ActiveRecordExtensions
122
+
123
+
124
+
125
+ with_options presence: true do
126
+
127
+ validates :product_name
128
+
129
+ validates :price
130
+
131
+ validates :image
132
+
133
+ end
134
+
135
+ end

1

書式の修正

2021/02/10 11:53

投稿

Fumi_Kazu5
Fumi_Kazu5

スコア1

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ターミナルにてテーブルに外部キーを作成しrails db:migrateすると以下のエラーが出てしまいます。原因が分からず途方に暮れています。
1
+ ターミナルにてテーブルに外部キーを作成しrails db:migrateすると以下のエラーが出てしまいます。原因が分からず途方に暮れています。 
2
2
 
3
3
  ご教授頂けると助かります。
4
4