質問編集履歴

5

rails rotue設定

2020/05/15 15:23

投稿

hanayoriinko
hanayoriinko

スコア3

test CHANGED
File without changes
test CHANGED
@@ -338,7 +338,45 @@
338
338
 
339
339
  ```
340
340
 
341
-
341
+ ルート結果。
342
+
343
+ ```
344
+
345
+ rails routes
346
+
347
+ Prefix Verb URI Pattern Controller#Action
348
+
349
+ books GET /books(.:format) books#index
350
+
351
+ POST /books(.:format) books#create
352
+
353
+ new_book GET /books/new(.:format) books#new
354
+
355
+ edit_book GET /books/:id/edit(.:format) books#edit
356
+
357
+ book GET /books/:id(.:format) books#show
358
+
359
+ PATCH /books/:id(.:format) books#update
360
+
361
+ PUT /books/:id(.:format) books#update
362
+
363
+ DELETE /books/:id(.:format) books#destroy
364
+
365
+ rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
366
+
367
+ rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
368
+
369
+ rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
370
+
371
+ update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
372
+
373
+ rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
374
+
375
+
376
+
377
+ コード
378
+
379
+ ```
342
380
 
343
381
  ### 試したこと
344
382
 

4

文法の修正

2020/05/15 15:23

投稿

hanayoriinko
hanayoriinko

スコア3

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,9 @@
10
10
 
11
11
 
12
12
 
13
+ ```
14
+
13
- ```Showing /home/vagrant/work/bookers1-debug/app/views/books/index.html.erb where line #23 raised:
15
+ Showing /home/vagrant/work/bookers1-debug/app/views/books/index.html.erb where line #23 raised:
14
16
 
15
17
  No route matches {:action=>"show", :controller=>"books"}, missing required keys: [:id]
16
18
 
@@ -44,7 +46,9 @@
44
46
 
45
47
  コントローラの記述
46
48
 
49
+ ```
50
+
47
- ```class BooksController < ApplicationController
51
+ class BooksController < ApplicationController
48
52
 
49
53
 
50
54
 
@@ -130,7 +134,9 @@
130
134
 
131
135
  book indexの記述
132
136
 
137
+ ```
138
+
133
- ```<% if flash[:notice] %>
139
+ <% if flash[:notice] %>
134
140
 
135
141
  <div class="flash"><%= flash[:notice] %></div>
136
142
 
@@ -198,7 +204,9 @@
198
204
 
199
205
  ```部分テンプレート部分
200
206
 
207
+ ```
208
+
201
- ```<% if flash[:notice] %>
209
+ <% if flash[:notice] %>
202
210
 
203
211
  <div class="flash"><%= flash[:notice] %></div>
204
212
 
@@ -268,7 +276,9 @@
268
276
 
269
277
  ```routse .rbの記述
270
278
 
279
+ ```
280
+
271
- ```Rails.application.routes.draw do
281
+ Rails.application.routes.draw do
272
282
 
273
283
 
274
284
 
@@ -280,13 +290,15 @@
280
290
 
281
291
 
282
292
 
283
- コード
293
+
284
294
 
285
295
  ```
286
296
 
287
297
  book.rbの記述
288
298
 
299
+ ```
300
+
289
- ```class Book < ApplicationRecord
301
+ class Book < ApplicationRecord
290
302
 
291
303
  validates :title,presence: true
292
304
 
@@ -300,7 +312,9 @@
300
312
 
301
313
  schema.rbの記述
302
314
 
315
+ ```
316
+
303
- ```ActiveRecord::Schema.define(version: 2020_05_15_114226) do
317
+ ActiveRecord::Schema.define(version: 2020_05_15_114226) do
304
318
 
305
319
 
306
320
 

3

modelの記述 schemaの記述 routse.rbの記述

2020/05/15 15:15

投稿

hanayoriinko
hanayoriinko

スコア3

test CHANGED
File without changes
test CHANGED
@@ -126,149 +126,203 @@
126
126
 
127
127
  end
128
128
 
129
+ ```
130
+
131
+ book indexの記述
132
+
133
+ ```<% if flash[:notice] %>
134
+
135
+ <div class="flash"><%= flash[:notice] %></div>
136
+
137
+ <% end %>
138
+
139
+
140
+
141
+ <h1>Books</h1>
142
+
143
+
144
+
145
+ <table>
146
+
147
+ <thead>
148
+
149
+ <tr>
150
+
151
+ <th>Title</th>
152
+
153
+ <th>Body</th>
154
+
155
+ <th colspan="3"></th>
156
+
157
+ </tr>
158
+
159
+ </thead>
160
+
161
+
162
+
163
+ <tbody>
164
+
165
+ <% @books.each do |book| %>
166
+
167
+ <tr>
168
+
169
+ <td><%= book.title %></td>
170
+
171
+ <td><%= book.body %></td>
172
+
173
+ <td><%= link_to 'Show', book_path(book)%></td>
174
+
175
+ <td><%= link_to 'Edit', edit_book_path(book)%></td>
176
+
177
+ <td><%= link_to 'Destroy', book_path, method: :delete, "data-confirm" => "Are you sure?" %></td>
178
+
179
+ </tr>
180
+
181
+ <% end %>
182
+
183
+ </tbody>
184
+
185
+ </table>
186
+
187
+
188
+
189
+
190
+
191
+ <h2>New book</h2>
192
+
193
+ <%= render 'form', book: @book %>
194
+
195
+
196
+
197
+
198
+
199
+ ```部分テンプレート部分
200
+
201
+ ```<% if flash[:notice] %>
202
+
203
+ <div class="flash"><%= flash[:notice] %></div>
204
+
205
+ <% end %>
206
+
207
+
208
+
209
+ <%= form_for book do |f|%>
210
+
211
+ <% if book.errors.any? %>
212
+
213
+ <div id="error_explanation">
214
+
215
+ <h2><%= pluralize(book.errors.count, "error") %> prohibited this book from being saved:</h2>
216
+
217
+
218
+
219
+ <ul>
220
+
221
+ <% book.errors.full_messages.each do |message| %>
222
+
223
+ <li><%= message %></li>
224
+
225
+ <% end %>
226
+
227
+ </ul>
228
+
229
+ </div>
230
+
231
+ <% end %>
232
+
233
+
234
+
235
+
236
+
237
+ <div class="field">
238
+
239
+ <%= f.label :title %>
240
+
241
+ <%= f.text_field :title, class: "book_title" %>
242
+
243
+ </div>
244
+
245
+
246
+
247
+ <div class="field">
248
+
249
+ <%= f.label :body %>
250
+
251
+ <%= f.text_area :body, class: "book_body" %>
252
+
253
+ </div>
254
+
255
+
256
+
257
+ <div class="actions">
258
+
259
+ <%= f.submit %>
260
+
261
+ </div>
262
+
263
+ <% end %>
264
+
265
+
266
+
267
+
268
+
269
+ ```routse .rbの記述
270
+
271
+ ```Rails.application.routes.draw do
272
+
273
+
274
+
275
+ resources :books
276
+
277
+
278
+
279
+ end
280
+
281
+
282
+
129
283
  コード
130
284
 
131
285
  ```
132
286
 
133
- book indexの記述
134
-
135
- ```<% if flash[:notice] %>
136
-
137
- <div class="flash"><%= flash[:notice] %></div>
138
-
139
- <% end %>
140
-
141
-
142
-
143
- <h1>Books</h1>
144
-
145
-
146
-
147
- <table>
148
-
149
- <thead>
150
-
151
- <tr>
152
-
153
- <th>Title</th>
154
-
155
- <th>Body</th>
156
-
157
- <th colspan="3"></th>
158
-
159
- </tr>
160
-
161
- </thead>
162
-
163
-
164
-
165
- <tbody>
166
-
167
- <% @books.each do |book| %>
168
-
169
- <tr>
170
-
171
- <td><%= book.title %></td>
172
-
173
- <td><%= book.body %></td>
174
-
175
- <td><%= link_to 'Show', book_path(book)%></td>
176
-
177
- <td><%= link_to 'Edit', edit_book_path(book)%></td>
178
-
179
- <td><%= link_to 'Destroy', book_path, method: :delete, "data-confirm" => "Are you sure?" %></td>
180
-
181
- </tr>
182
-
183
- <% end %>
184
-
185
- </tbody>
186
-
187
- </table>
188
-
189
-
190
-
191
-
192
-
193
- <h2>New book</h2>
194
-
195
- <%= render 'form', book: @book %>
196
-
197
-
198
-
199
- コード
200
-
201
- ```部分テンプレート部分
202
-
203
- ```<% if flash[:notice] %>
204
-
205
- <div class="flash"><%= flash[:notice] %></div>
206
-
207
- <% end %>
208
-
209
-
210
-
211
- <%= form_for book do |f|%>
212
-
213
- <% if book.errors.any? %>
214
-
215
- <div id="error_explanation">
216
-
217
- <h2><%= pluralize(book.errors.count, "error") %> prohibited this book from being saved:</h2>
218
-
219
-
220
-
221
- <ul>
222
-
223
- <% book.errors.full_messages.each do |message| %>
224
-
225
- <li><%= message %></li>
226
-
227
- <% end %>
228
-
229
- </ul>
230
-
231
- </div>
232
-
233
- <% end %>
234
-
235
-
236
-
237
-
238
-
239
- <div class="field">
240
-
241
- <%= f.label :title %>
242
-
243
- <%= f.text_field :title, class: "book_title" %>
244
-
245
- </div>
246
-
247
-
248
-
249
- <div class="field">
250
-
251
- <%= f.label :body %>
252
-
253
- <%= f.text_area :body, class: "book_body" %>
254
-
255
- </div>
256
-
257
-
258
-
259
- <div class="actions">
260
-
261
- <%= f.submit %>
262
-
263
- </div>
264
-
265
- <% end %>
266
-
267
- コード
268
-
269
- ```
270
-
271
-
287
+ book.rbの記述
288
+
289
+ ```class Book < ApplicationRecord
290
+
291
+ validates :title,presence: true
292
+
293
+ validates :body,presence: true
294
+
295
+ end
296
+
297
+
298
+
299
+ ```
300
+
301
+ schema.rbの記述
302
+
303
+ ```ActiveRecord::Schema.define(version: 2020_05_15_114226) do
304
+
305
+
306
+
307
+ create_table "books", force: :cascade do |t|
308
+
309
+ t.text "body"
310
+
311
+ t.datetime "created_at", null: false
312
+
313
+ t.datetime "updated_at", null: false
314
+
315
+ t.string "title"
316
+
317
+ end
318
+
319
+
320
+
321
+ end
322
+
323
+
324
+
325
+ ```
272
326
 
273
327
 
274
328
 

2

誤字

2020/05/15 14:52

投稿

hanayoriinko
hanayoriinko

スコア3

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- railsmissing required keys: [:id]というエラーが解決できません。
5
+ rails missing required keys: [:id]というエラーが解決できません。
6
6
 
7
7
  当方rails初心者です。質問させて頂きます。
8
8
 

1

文法の修正 book ソースコードの記述

2020/05/15 14:29

投稿

hanayoriinko
hanayoriinko

スコア3

test CHANGED
File without changes
test CHANGED
@@ -4,21 +4,19 @@
4
4
 
5
5
  railsmissing required keys: [:id]というエラーが解決できません。
6
6
 
7
- 当方rails初心者質問させて頂きます。
7
+ 当方rails初心者です。質問させて頂きます。
8
-
9
-
10
-
11
- ### 発生している問題・エラーメッセージ
8
+
12
-
13
-
14
-
9
+
10
+
11
+
12
+
15
- Showing /home/vagrant/work/bookers1-debug/app/views/books/index.html.erb where line #23 raised:
13
+ ```Showing /home/vagrant/work/bookers1-debug/app/views/books/index.html.erb where line #23 raised:
16
14
 
17
15
  No route matches {:action=>"show", :controller=>"books"}, missing required keys: [:id]
18
16
 
19
17
 
20
18
 
21
- <td><%= link_to 'Show', book_path(book)%></td>
19
+ <td><%= link_to 'Show', book_path(book)%></td>
22
20
 
23
21
  <td><%= link_to 'Edit', edit_book_path(book)%></td>
24
22
 
@@ -30,6 +28,14 @@
30
28
 
31
29
 
32
30
 
31
+ コード
32
+
33
+ ```
34
+
35
+
36
+
37
+
38
+
33
39
 
34
40
 
35
41
 
@@ -38,7 +44,7 @@
38
44
 
39
45
  コントローラの記述
40
46
 
41
- class BooksController < ApplicationController
47
+ ```class BooksController < ApplicationController
42
48
 
43
49
 
44
50
 
@@ -120,7 +126,147 @@
120
126
 
121
127
  end
122
128
 
123
-
129
+ コード
130
+
131
+ ```
132
+
133
+ book indexの記述
134
+
135
+ ```<% if flash[:notice] %>
136
+
137
+ <div class="flash"><%= flash[:notice] %></div>
138
+
139
+ <% end %>
140
+
141
+
142
+
143
+ <h1>Books</h1>
144
+
145
+
146
+
147
+ <table>
148
+
149
+ <thead>
150
+
151
+ <tr>
152
+
153
+ <th>Title</th>
154
+
155
+ <th>Body</th>
156
+
157
+ <th colspan="3"></th>
158
+
159
+ </tr>
160
+
161
+ </thead>
162
+
163
+
164
+
165
+ <tbody>
166
+
167
+ <% @books.each do |book| %>
168
+
169
+ <tr>
170
+
171
+ <td><%= book.title %></td>
172
+
173
+ <td><%= book.body %></td>
174
+
175
+ <td><%= link_to 'Show', book_path(book)%></td>
176
+
177
+ <td><%= link_to 'Edit', edit_book_path(book)%></td>
178
+
179
+ <td><%= link_to 'Destroy', book_path, method: :delete, "data-confirm" => "Are you sure?" %></td>
180
+
181
+ </tr>
182
+
183
+ <% end %>
184
+
185
+ </tbody>
186
+
187
+ </table>
188
+
189
+
190
+
191
+
192
+
193
+ <h2>New book</h2>
194
+
195
+ <%= render 'form', book: @book %>
196
+
197
+
198
+
199
+ コード
200
+
201
+ ```部分テンプレート部分
202
+
203
+ ```<% if flash[:notice] %>
204
+
205
+ <div class="flash"><%= flash[:notice] %></div>
206
+
207
+ <% end %>
208
+
209
+
210
+
211
+ <%= form_for book do |f|%>
212
+
213
+ <% if book.errors.any? %>
214
+
215
+ <div id="error_explanation">
216
+
217
+ <h2><%= pluralize(book.errors.count, "error") %> prohibited this book from being saved:</h2>
218
+
219
+
220
+
221
+ <ul>
222
+
223
+ <% book.errors.full_messages.each do |message| %>
224
+
225
+ <li><%= message %></li>
226
+
227
+ <% end %>
228
+
229
+ </ul>
230
+
231
+ </div>
232
+
233
+ <% end %>
234
+
235
+
236
+
237
+
238
+
239
+ <div class="field">
240
+
241
+ <%= f.label :title %>
242
+
243
+ <%= f.text_field :title, class: "book_title" %>
244
+
245
+ </div>
246
+
247
+
248
+
249
+ <div class="field">
250
+
251
+ <%= f.label :body %>
252
+
253
+ <%= f.text_area :body, class: "book_body" %>
254
+
255
+ </div>
256
+
257
+
258
+
259
+ <div class="actions">
260
+
261
+ <%= f.submit %>
262
+
263
+ </div>
264
+
265
+ <% end %>
266
+
267
+ コード
268
+
269
+ ```
124
270
 
125
271
 
126
272
 
@@ -131,13 +277,3 @@
131
277
 
132
278
 
133
279
  No route matchesが出ていたため、コントローラのshowのrouteを確認したり,createのrenderなどを変更しましたが解決できず、ご質問させていただきます。
134
-
135
-
136
-
137
-
138
-
139
- ### 補足情報(FW/ツールのバージョンなど)
140
-
141
-
142
-
143
- ここにより詳細な情報を記載してください。