質問編集履歴

5

出力画面の追記

2019/01/07 11:02

投稿

-maeji-
-maeji-

スコア39

test CHANGED
File without changes
test CHANGED
@@ -301,3 +301,7 @@
301
301
  end
302
302
 
303
303
  ```
304
+
305
+ 現在の状態
306
+
307
+ ![イメージ説明](7fb90318cdfef8fabe9b379d079888c5.png)

4

<tb>が間違っていたので<td>に修正しました

2019/01/07 11:02

投稿

-maeji-
-maeji-

スコア39

test CHANGED
File without changes
test CHANGED
@@ -60,21 +60,21 @@
60
60
 
61
61
  <tr>
62
62
 
63
- <tb><%= book.title %></tb>
63
+ <td><%= book.title %></td>
64
-
64
+
65
- <tb><%= book.text %></tb>
65
+ <td><%= book.text %></td>
66
-
66
+
67
- <tb><%= link_to '表示',book_path(book) %></tb>
67
+ <td><%= link_to '表示',book_path(book) %></td>
68
-
68
+
69
- <tb><%= link_to '編集',edit_book_path(book) %></tb>
69
+ <td><%= link_to '編集',edit_book_path(book) %></td>
70
-
70
+
71
- <tb><%= link_to '削除',book_path(book),
71
+ <td><%= link_to '削除',book_path(book),
72
72
 
73
73
  method: :delete,
74
74
 
75
75
  data: {confirm: '本当に削除してもいいですか?'} %>
76
76
 
77
- </tb>
77
+ </td>
78
78
 
79
79
  </tr>
80
80
 
@@ -82,6 +82,8 @@
82
82
 
83
83
  </table>
84
84
 
85
+
86
+
85
87
  ```
86
88
 
87
89
 

3

book.rbの追加

2019/01/07 10:49

投稿

-maeji-
-maeji-

スコア39

test CHANGED
File without changes
test CHANGED
@@ -285,3 +285,17 @@
285
285
  <%= link_to '戻る',books_path %>
286
286
 
287
287
  ```
288
+
289
+
290
+
291
+ ##book.rb
292
+
293
+ ```
294
+
295
+ class Book < ApplicationRecord
296
+
297
+ validates :title, presence: true,length: {minimum: 5}
298
+
299
+ end
300
+
301
+ ```

2

追記とeditのビューの追加

2019/01/07 10:37

投稿

-maeji-
-maeji-

スコア39

test CHANGED
File without changes
test CHANGED
@@ -22,6 +22,16 @@
22
22
 
23
23
  以下が編集した内容です。よろしくお願いいたします。
24
24
 
25
+ :追記
26
+
27
+ edit.html.erbの``<%= form_for(@book) do |f| %>``は、``<%= form_for :book, url: books_path(@book),method: :patch do |f| %>``から変更したものです。ここに原因がありますでしょうか
28
+
29
+
30
+
31
+
32
+
33
+
34
+
25
35
  ###index.html.erb
26
36
 
27
37
  ```
@@ -227,3 +237,51 @@
227
237
  <%= link_to '戻る',books_path %>
228
238
 
229
239
  ```
240
+
241
+
242
+
243
+ ###edit.html.erb
244
+
245
+ ```
246
+
247
+ <h1>書籍を編集する</h1>
248
+
249
+
250
+
251
+ <%= form_for(@book) do |f| %>
252
+
253
+
254
+
255
+ <p>
256
+
257
+ <%= f.label :title %>
258
+
259
+ <%= f.text_field :title %>
260
+
261
+ </p>
262
+
263
+
264
+
265
+ <p>
266
+
267
+ <%= f.label :text %>
268
+
269
+ <%= f.text_area :text %>
270
+
271
+ </p>
272
+
273
+
274
+
275
+ <p>
276
+
277
+ <%= f.submit %>
278
+
279
+ </p>
280
+
281
+
282
+
283
+ <% end %>
284
+
285
+ <%= link_to '戻る',books_path %>
286
+
287
+ ```

1

new.html.erbの追加

2019/01/07 10:25

投稿

-maeji-
-maeji-

スコア39

test CHANGED
File without changes
test CHANGED
@@ -181,3 +181,49 @@
181
181
  end
182
182
 
183
183
  ```
184
+
185
+
186
+
187
+ ###new.html.erb
188
+
189
+ ```
190
+
191
+ <h1>新しい書籍</h1>
192
+
193
+
194
+
195
+ <%= form_for :book, url: books_path do |f| %>
196
+
197
+ <p>
198
+
199
+ <%= f.label :title %>
200
+
201
+ <%= f.text_field :title %>
202
+
203
+ </p>
204
+
205
+
206
+
207
+ <p>
208
+
209
+ <%= f.label :text %>
210
+
211
+ <%= f.text_area :text %>
212
+
213
+ </p>
214
+
215
+
216
+
217
+ <p>
218
+
219
+ <%= f.submit %>
220
+
221
+ </p>
222
+
223
+
224
+
225
+ <% end %>
226
+
227
+ <%= link_to '戻る',books_path %>
228
+
229
+ ```