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

質問編集履歴

3

内容の変更

2021/02/10 12:08

投稿

Fumi_Kazu5
Fumi_Kazu5

スコア1

title CHANGED
File without changes
body CHANGED
@@ -40,6 +40,9 @@
40
40
 
41
41
 
42
42
 
43
+
44
+
45
+
43
46
  説明が足りなくてすみません。追加記入です。
44
47
  rails db:migrate:statusの結果
45
48
 
@@ -65,4 +68,18 @@
65
68
  validates :price
66
69
  validates :image
67
70
  end
71
+ end
72
+
73
+
74
+ データベース
75
+ class CreateShoppings < ActiveRecord::Migration[6.0]
76
+ def change
77
+ create_table :shoppings do |t|
78
+ t.string :product_name, null: false
79
+ t.integer :price, null: false
80
+ #t.references :owner, foreign_key: true
81
+
82
+ t.timestamps
83
+ end
84
+ end
68
85
  end

2

内容の変更

2021/02/10 12:08

投稿

Fumi_Kazu5
Fumi_Kazu5

スコア1

title CHANGED
File without changes
body CHANGED
@@ -36,4 +36,33 @@
36
36
  bin/rails:3:in `load'
37
37
  bin/rails:3:in `<main>'
38
38
  Tasks: TOP => db:migrate
39
- (See full trace by running task with --trace)
39
+ (See full trace by running task with --trace)
40
+
41
+
42
+
43
+ 説明が足りなくてすみません。追加記入です。
44
+ rails db:migrate:statusの結果
45
+
46
+ database: tomori_app_development
47
+
48
+ Status Migration ID Migration Name
49
+ --------------------------------------------------
50
+ up 20210126060600 Devise create users
51
+ up 20210126062512 Create active storage tablesactive storage
52
+ up 20210129112855 Create shoppings
53
+ up 20210131072013 Create orders
54
+ up 20210131143313 Devise create owners
55
+
56
+ モデルの記入内容
57
+ class Shopping < ApplicationRecord
58
+ belongs_to :owner, optional: true, foreign_key: :owner_id
59
+ has_one :order
60
+ has_one_attached :image
61
+ # extend ActiveHash::Associations::ActiveRecordExtensions
62
+
63
+ with_options presence: true do
64
+ validates :product_name
65
+ validates :price
66
+ validates :image
67
+ end
68
+ end

1

書式の修正

2021/02/10 11:53

投稿

Fumi_Kazu5
Fumi_Kazu5

スコア1

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