質問編集履歴

1

モデルを追加させていただきました。

2021/04/01 03:47

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -38,7 +38,147 @@
38
38
 
39
39
  ### 該当のソースコード
40
40
 
41
+ models/action.rb
42
+
43
+ ```
44
+
45
+ class Action < ApplicationRecord
46
+
47
+
48
+
49
+ extend ActiveHash::Associations::ActiveRecordExtensions
50
+
51
+
52
+
53
+ belongs_to_active_hash :active
54
+
55
+ belongs_to_active_hash :place
56
+
57
+ belongs_to_active_hash :set_time
58
+
59
+
60
+
61
+ with_options numericality: { other_than: 0 } do
62
+
63
+ validates :active_id
64
+
65
+ validates :place_id
66
+
67
+ validates :set_time_id
68
+
69
+ end
70
+
71
+
72
+
73
+ belongs_to :user
74
+
75
+ end
76
+
77
+
78
+
79
+ ```
80
+
81
+
82
+
83
+ ### 該当のソースコード
84
+
85
+ models/active.rb
86
+
87
+ ```
88
+
89
+ class Active < ActiveHash::Base
90
+
91
+
92
+
93
+ self.data = [
94
+
95
+ {id: 0, name: '---'},
96
+
97
+ {id: 1, name: '読書'},
98
+
99
+ {id: 2, name: '筋トレ'},
100
+
101
+ {id: 3, name: 'ランニング'},
102
+
103
+ {id: 4, name: 'ウォーキング'},
104
+
105
+ {id: 5, name: 'プログラミング'},
106
+
107
+ {id: 6, name: '英会話'},
108
+
109
+ {id: 7, name: '勉強'},
110
+
111
+ {id: 8, name: '瞑想'},
112
+
113
+ {id: 9, name: '掃除'},
114
+
115
+ {id: 10, name: 'その他'}
116
+
117
+ ]
118
+
119
+
120
+
121
+ include ActiveHash::Associations
122
+
123
+ has_many :actions
124
+
125
+ end
126
+
127
+
128
+
129
+ ```
130
+
131
+
132
+
133
+ ### 該当のソースコード
134
+
135
+ models/place.rb
136
+
137
+ ```
138
+
139
+ class Place < ActiveHash::Base
140
+
141
+
142
+
143
+ self.data = [
144
+
145
+ {id: 0, name: '---'},
146
+
147
+ {id: 1, name: '自宅'},
148
+
149
+ {id: 2, name: '公園'},
150
+
151
+ {id: 3, name: 'ジム'},
152
+
153
+ {id: 4, name: '職場'},
154
+
155
+ {id: 5, name: '教室'},
156
+
157
+ {id: 6, name: 'カフェ'},
158
+
159
+ {id: 7, name: '図書館'},
160
+
161
+ {id: 8, name: '屋外'},
162
+
163
+ {id: 9, name: 'その他'}
164
+
165
+ ]
166
+
167
+
168
+
169
+ include ActiveHash::Associations
170
+
171
+ has_many :actions
172
+
173
+ end
174
+
175
+ ```
176
+
177
+
178
+
179
+ ### 該当のソースコード
180
+
41
- config/routes.rb
181
+ models/routes.rb
42
182
 
43
183
  ```
44
184
 
@@ -60,6 +200,60 @@
60
200
 
61
201
  ### 該当のソースコード
62
202
 
203
+ config/set_time.rb
204
+
205
+ ```
206
+
207
+ class SetTime < ActiveHash::Base
208
+
209
+
210
+
211
+ self.data = [
212
+
213
+ {id: 0, name: '---'},
214
+
215
+ {id: 1, name: '15分'},
216
+
217
+ {id: 2, name: '30分'},
218
+
219
+ {id: 3, name: '45分'},
220
+
221
+ {id: 4, name: '1時間00分'},
222
+
223
+ {id: 5, name: '1時間15分'},
224
+
225
+ {id: 6, name: '1時間30分'},
226
+
227
+ {id: 7, name: '1時間45分'},
228
+
229
+ {id: 8, name: '2時間00分'},
230
+
231
+ {id: 9, name: '2時間15分'},
232
+
233
+ {id: 10, name: '2時間30分'},
234
+
235
+ {id: 11, name: '2時間45分'},
236
+
237
+ {id: 12, name: '3時間00分'},
238
+
239
+ {id: 13, name: '3時間以上'}
240
+
241
+ ]
242
+
243
+
244
+
245
+ include ActiveHash::Associations
246
+
247
+ has_many :actions
248
+
249
+ end
250
+
251
+ ```
252
+
253
+
254
+
255
+ ### 該当のソースコード
256
+
63
257
  actions_controller
64
258
 
65
259
  ```