質問編集履歴
1
modelの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -63,3 +63,51 @@
|
|
63
63
|
|
64
64
|
|
65
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
#priceモデル
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
class Price < ApplicationRecord
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
belongs_to :person, optional: true
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
validates :service, :price, presence: true
|
84
|
+
|
85
|
+
validates :service, length: { maximum: 30 }
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
#personモデル
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
class Person < ApplicationRecord
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
has_many :prices, dependent: :destroy
|
102
|
+
|
103
|
+
accepts_nested_attributes_for :prices, allow_destroy: true
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
validates :name, :gender, :contact, :sample, :comment, presence: true
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
```
|