質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -224,6 +224,92 @@
|
|
224
224
|
|
225
225
|
```
|
226
226
|
|
227
|
+
```ruby
|
228
|
+
|
229
|
+
incomeモデル(収入)
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
class Income < ApplicationRecord
|
234
|
+
|
235
|
+
with_options presence: true do
|
236
|
+
|
237
|
+
validates :price, inclusion: { in: 1..100000000 }, format: {with: /\A[0-9]+\z/}, numericality: true
|
238
|
+
|
239
|
+
validates :category
|
240
|
+
|
241
|
+
validates :memo
|
242
|
+
|
243
|
+
validates :date
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
def start_time
|
250
|
+
|
251
|
+
self.date
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
belongs_to :user
|
264
|
+
|
265
|
+
end
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
```ruby
|
274
|
+
|
275
|
+
spendingモデル(支出)
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
class Spending < ApplicationRecord
|
280
|
+
|
281
|
+
with_options presence: true do
|
282
|
+
|
283
|
+
validates :price, inclusion: { in: 1..100000000 }, format: {with: /\A[0-9]+\z/}, numericality: true
|
284
|
+
|
285
|
+
validates :category
|
286
|
+
|
287
|
+
validates :memo
|
288
|
+
|
289
|
+
validates :date
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
def start_time
|
296
|
+
|
297
|
+
self.date
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
belongs_to :user
|
306
|
+
|
307
|
+
end
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
```
|
312
|
+
|
227
313
|
|
228
314
|
|
229
315
|
### 試したこと
|