質問編集履歴
2
追記いたしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,4 +94,140 @@
|
|
94
94
|
|
95
95
|
```
|
96
96
|
|
97
|
+
```ここに言語を入力
|
98
|
+
|
99
|
+
db/fixtures/prefecture.rb
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
Prefecture.seed(:id,
|
106
|
+
|
107
|
+
{ :id => 0, :name => "北海道" },
|
108
|
+
|
109
|
+
{ :id => 1, :name => "青森県" },
|
110
|
+
|
111
|
+
{ :id => 2, :name => "岩手県" },
|
112
|
+
|
113
|
+
{ :id => 3, :name => "宮城県" },
|
114
|
+
|
115
|
+
{ :id => 4, :name => "秋田県" },
|
116
|
+
|
117
|
+
{ :id => 5, :name => "山形県" },
|
118
|
+
|
119
|
+
{ :id => 6, :name => "福島県" },
|
120
|
+
|
121
|
+
{ :id => 7, :name => "茨城県" },
|
122
|
+
|
123
|
+
{ :id => 8, :name => "栃木県" },
|
124
|
+
|
125
|
+
{ :id => 9, :name => "群馬県" },
|
126
|
+
|
127
|
+
{ :id => 10, :name => "埼玉県" },
|
128
|
+
|
129
|
+
{ :id => 11, :name => "千葉県" },
|
130
|
+
|
131
|
+
{ :id => 12, :name => "東京都" },
|
132
|
+
|
133
|
+
{ :id => 13, :name => "神奈川県" },
|
134
|
+
|
135
|
+
{ :id => 14, :name => "新潟県" },
|
136
|
+
|
137
|
+
{ :id => 15, :name => "富山県" },
|
138
|
+
|
139
|
+
{ :id => 16, :name => "石川県" },
|
140
|
+
|
141
|
+
{ :id => 17, :name => "福井県" },
|
142
|
+
|
143
|
+
{ :id => 18, :name => "山梨県" },
|
144
|
+
|
145
|
+
{ :id => 19, :name => "長野県" },
|
146
|
+
|
147
|
+
{ :id => 20, :name => "岐阜県" },
|
148
|
+
|
149
|
+
{ :id => 21, :name => "静岡県" },
|
150
|
+
|
151
|
+
{ :id => 22, :name => "愛知県" },
|
152
|
+
|
153
|
+
{ :id => 23, :name => "三重県" },
|
154
|
+
|
155
|
+
{ :id => 24, :name => "滋賀県" },
|
156
|
+
|
157
|
+
{ :id => 25, :name => "京都府" },
|
158
|
+
|
159
|
+
{ :id => 26, :name => "大阪府" },
|
160
|
+
|
161
|
+
{ :id => 27, :name => "兵庫県" },
|
162
|
+
|
163
|
+
{ :id => 28, :name => "奈良県" },
|
164
|
+
|
165
|
+
{ :id => 29, :name => "和歌山県" },
|
166
|
+
|
167
|
+
{ :id => 30, :name => "鳥取県" },
|
168
|
+
|
169
|
+
{ :id => 31, :name => "島根県" },
|
170
|
+
|
171
|
+
{ :id => 32, :name => "岡山県" },
|
172
|
+
|
173
|
+
{ :id => 33, :name => "広島県" },
|
174
|
+
|
175
|
+
{ :id => 34, :name => "山口県" },
|
176
|
+
|
177
|
+
{ :id => 35, :name => "徳島県" },
|
178
|
+
|
179
|
+
{ :id => 36, :name => "香川県" },
|
180
|
+
|
181
|
+
{ :id => 37, :name => "愛媛県" },
|
182
|
+
|
183
|
+
{ :id => 38, :name => "高知県" },
|
184
|
+
|
185
|
+
{ :id => 39, :name => "福岡県" },
|
186
|
+
|
187
|
+
{ :id => 40, :name => "佐賀県" },
|
188
|
+
|
189
|
+
{ :id => 41, :name => "長崎県" },
|
190
|
+
|
191
|
+
{ :id => 42, :name => "熊本県" },
|
192
|
+
|
193
|
+
{ :id => 43, :name => "大分県" },
|
194
|
+
|
195
|
+
{ :id => 44, :name => "宮崎県" },
|
196
|
+
|
197
|
+
{ :id => 45, :name => "鹿児島県" },
|
198
|
+
|
199
|
+
{ :id => 46, :name => "沖縄県" }
|
200
|
+
|
201
|
+
)
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
```ここに言語を入力
|
208
|
+
|
209
|
+
db/fixtures/split.rb
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
Split.seed(:id,
|
216
|
+
|
217
|
+
{ :id => 0, :name => "胸" },
|
218
|
+
|
219
|
+
{ :id => 1, :name => "背中" },
|
220
|
+
|
221
|
+
{ :id => 2, :name => "肩" },
|
222
|
+
|
223
|
+
{ :id => 3, :name => "腕" },
|
224
|
+
|
225
|
+
{ :id => 4, :name => "脚" },
|
226
|
+
|
227
|
+
{ :id => 5, :name => "腹筋" }
|
228
|
+
|
229
|
+
)
|
230
|
+
|
231
|
+
```
|
232
|
+
|
97
233
|
ご教授お願いいたします。
|
1
追記いたしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
モデルにはuser, micropost, relationship, prefecture, splitを使っており、micropostはbelongs_toで、user, prefecture, splitをidで関連づけております。
|
6
6
|
|
7
7
|
micropostを作成した際に、content, user_id, prefecture_id, split_idを必須にしているのですが、prefecture_idとsplit_idをランダムにデモデータとして登録するにはどのように記述したらよろしいのでしょうか?
|
8
|
+
|
9
|
+
prefectureとsplitに関してはseed_fuで登録してあります。
|
8
10
|
|
9
11
|
以下がコードになります。
|
10
12
|
|