質問編集履歴

5

誤字

2021/07/11 06:03

投稿

isd_kisk
isd_kisk

スコア15

test CHANGED
File without changes
test CHANGED
@@ -26,21 +26,9 @@
26
26
 
27
27
 
28
28
 
29
-
30
-
31
- ### 該当のソースコード
32
-
33
- ```ruby
34
-
35
- コード
36
-
37
- ``> ``````**books_controller.rb**
38
-
39
29
  class BooksController < ApplicationController
40
30
 
41
-
42
-
43
-
31
+
44
32
 
45
33
  def top
46
34
 
@@ -144,6 +132,10 @@
144
132
 
145
133
  end
146
134
 
135
+ ```
136
+
137
+ ```
138
+
147
139
 
148
140
 
149
141
 
@@ -248,7 +240,15 @@
248
240
 
249
241
 
250
242
 
243
+
244
+
245
+
246
+
247
+ ```
248
+
251
- **__routes.rb__**
249
+ ```**__routes.rb__**
250
+
251
+ ```**__routes.rb__**
252
252
 
253
253
 
254
254
 
@@ -266,14 +266,6 @@
266
266
 
267
267
 
268
268
 
269
-
270
-
271
- ここに言語を入力
272
-
273
- ```
274
-
275
- 引用テキスト
276
-
277
269
  ```
278
270
 
279
271
 

4

2021/07/11 06:03

投稿

isd_kisk
isd_kisk

スコア15

test CHANGED
File without changes
test CHANGED
@@ -250,6 +250,8 @@
250
250
 
251
251
  **__routes.rb__**
252
252
 
253
+
254
+
253
255
  Rails.application.routes.draw do
254
256
 
255
257
  resources :books

3

2021/07/11 03:02

投稿

isd_kisk
isd_kisk

スコア15

test CHANGED
File without changes
test CHANGED
@@ -148,9 +148,9 @@
148
148
 
149
149
 
150
150
 
151
- **index.html.erb
151
+ ***__*index.html.erb__**
152
-
153
- **
152
+
153
+
154
154
 
155
155
  <h1>Books</h1>
156
156
 
@@ -212,9 +212,9 @@
212
212
 
213
213
  </div>
214
214
 
215
- **
215
+
216
-
216
+
217
- new.html.erb**
217
+ **__new.html.erb**__
218
218
 
219
219
 
220
220
 
@@ -248,7 +248,7 @@
248
248
 
249
249
 
250
250
 
251
- routes.rb
251
+ **__routes.rb__**
252
252
 
253
253
  Rails.application.routes.draw do
254
254
 

2

2021/07/11 03:01

投稿

isd_kisk
isd_kisk

スコア15

test CHANGED
File without changes
test CHANGED
@@ -38,7 +38,9 @@
38
38
 
39
39
  class BooksController < ApplicationController
40
40
 
41
-
41
+
42
+
43
+
42
44
 
43
45
  def top
44
46
 

1

2021/07/11 02:59

投稿

isd_kisk
isd_kisk

スコア15

test CHANGED
File without changes
test CHANGED
@@ -34,241 +34,243 @@
34
34
 
35
35
  コード
36
36
 
37
+ ``> ``````**books_controller.rb**
38
+
39
+ class BooksController < ApplicationController
40
+
41
+
42
+
43
+ def top
44
+
45
+ end
46
+
47
+
48
+
49
+ def index
50
+
51
+ @books = Book.all
52
+
53
+ end
54
+
55
+
56
+
57
+ def show
58
+
59
+ @book = Book.find(params[:id])
60
+
61
+ end
62
+
63
+
64
+
65
+ def new
66
+
67
+ @book = Book.new
68
+
69
+ end
70
+
71
+
72
+
73
+ def create
74
+
75
+ @book = Book.new(book_params)
76
+
77
+ if @book.save
78
+
79
+ flash[:notice] ="Book was successfully created."
80
+
81
+ redirect_to book_path(@book)
82
+
83
+ else
84
+
85
+ render "new"
86
+
87
+ end
88
+
89
+ end
90
+
91
+ def edit
92
+
93
+ @book = Book.find(params[:id])
94
+
95
+ end
96
+
97
+
98
+
99
+ def update
100
+
101
+ @book = Book.find(params[:id])
102
+
103
+ if @book.update(book_params)
104
+
105
+ flash[:notify] = "Book was successfully updated."
106
+
107
+ redirect_to book_path(@book)
108
+
109
+ else
110
+
111
+ render "index"
112
+
113
+ end
114
+
115
+ end
116
+
117
+
118
+
119
+ def destroy
120
+
121
+ @book = Book.find(params[:id])
122
+
123
+ @book.destroy
124
+
125
+ if @book.destroy
126
+
127
+ flash[:message] = "Book was successfully destroyed."
128
+
129
+ redirect_to books_path
130
+
131
+ end
132
+
133
+ end
134
+
135
+ private
136
+
137
+ def book_params
138
+
139
+ params.permit(:title, :body)
140
+
141
+ end
142
+
143
+ end
144
+
145
+
146
+
147
+
148
+
149
+ **index.html.erb
150
+
151
+ **
152
+
153
+ <h1>Books</h1>
154
+
155
+ <div class = "wrapp">
156
+
157
+ <table>
158
+
159
+ <tr>
160
+
161
+ <td class = "data">Title</td>
162
+
163
+ <td class = "data1">Body</td>
164
+
165
+ </tr>
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.id), method: :get %></td>
176
+
177
+ <td><%= link_to 'Edit', book_path(book.id), method: :get %></td>
178
+
179
+ <td><%= link_to 'destroy',book_path(book.id),method: :delete, data: {confirm:"Are you sure?"}%></td>
180
+
181
+ </tr>
182
+
183
+ <% end %>
184
+
185
+ </table>
186
+
187
+
188
+
189
+ <%= form_with model:@book, local:true do |f| %>
190
+
191
+ <h1>New book</h1>
192
+
193
+ <h4>Title</h4>
194
+
195
+ <%= f.text_field :title %>
196
+
197
+ <h4>Body</h4>
198
+
199
+
200
+
201
+ <%= f.text_area :body %>
202
+
203
+
204
+
205
+ <%= f.submit 'create book' %>
206
+
207
+ <% end %>
208
+
209
+
210
+
211
+ </div>
212
+
213
+ **
214
+
215
+ new.html.erb**
216
+
217
+
218
+
219
+ <%= form_with model:@book, local:true do |f| %>
220
+
221
+
222
+
223
+ <% if @book.errors.any? %>
224
+
225
+ <div class = "title">
226
+
227
+ <ul>
228
+
229
+ <h3><span = class = "warn"><%= @book.errors.count %> error prohibited this book from being saved:</h3>
230
+
231
+ <h3><% @book.errors.full_messages.each do |message| %></h3>
232
+
233
+ <li><%= message %></li>
234
+
235
+ <% end %>
236
+
237
+ </ul>
238
+
239
+ </div>
240
+
241
+ <% end %>
242
+
243
+
244
+
245
+ <% end %>
246
+
247
+
248
+
249
+ routes.rb
250
+
251
+ Rails.application.routes.draw do
252
+
253
+ resources :books
254
+
255
+ delete 'books/:id', to: 'books#destroy'
256
+
257
+ **# For details on the DSL available within this file, see **http://guides.rubyonrails.org/routing.html
258
+
259
+ root to: 'books#top'
260
+
261
+ end
262
+
263
+
264
+
265
+
266
+
267
+ ここに言語を入力
268
+
37
269
  ```
38
270
 
39
- **books_controller.rb**
40
-
41
- class BooksController < ApplicationController
42
-
43
-
44
-
45
- def top
271
+ 引用テキスト
46
-
272
+
47
- end
273
+ ```
48
-
49
-
50
-
51
- def index
52
-
53
- @books = Book.all
54
-
55
- end
56
-
57
-
58
-
59
- def show
60
-
61
- @book = Book.find(params[:id])
62
-
63
- end
64
-
65
-
66
-
67
- def new
68
-
69
- @book = Book.new
70
-
71
- end
72
-
73
-
74
-
75
- def create
76
-
77
- @book = Book.new(book_params)
78
-
79
- if @book.save
80
-
81
- flash[:notice] ="Book was successfully created."
82
-
83
- redirect_to book_path(@book)
84
-
85
- else
86
-
87
- render "new"
88
-
89
- end
90
-
91
- end
92
-
93
- def edit
94
-
95
- @book = Book.find(params[:id])
96
-
97
- end
98
-
99
-
100
-
101
- def update
102
-
103
- @book = Book.find(params[:id])
104
-
105
- if @book.update(book_params)
106
-
107
- flash[:notify] = "Book was successfully updated."
108
-
109
- redirect_to book_path(@book)
110
-
111
- else
112
-
113
- render "index"
114
-
115
- end
116
-
117
- end
118
-
119
-
120
-
121
- def destroy
122
-
123
- @book = Book.find(params[:id])
124
-
125
- @book.destroy
126
-
127
- if @book.destroy
128
-
129
- flash[:message] = "Book was successfully destroyed."
130
-
131
- redirect_to books_path
132
-
133
- end
134
-
135
- end
136
-
137
- private
138
-
139
- def book_params
140
-
141
- params.permit(:title, :body)
142
-
143
- end
144
-
145
- end
146
-
147
-
148
-
149
-
150
-
151
- **index.html.erb
152
-
153
- **
154
-
155
- <h1>Books</h1>
156
-
157
- <div class = "wrapp">
158
-
159
- <table>
160
-
161
- <tr>
162
-
163
- <td class = "data">Title</td>
164
-
165
- <td class = "data1">Body</td>
166
-
167
- </tr>
168
-
169
- <% @books.each do |book| %>
170
-
171
- <tr>
172
-
173
- <td><%= book.title %></td>
174
-
175
- <td><%= book.body %></td>
176
-
177
- <td><%= link_to 'Show', book_path(book.id), method: :get %></td>
178
-
179
- <td><%= link_to 'Edit', book_path(book.id), method: :get %></td>
180
-
181
- <td><%= link_to 'destroy',book_path(book.id),method: :delete, data: {confirm:"Are you sure?"}%></td>
182
-
183
- </tr>
184
-
185
- <% end %>
186
-
187
- </table>
188
-
189
-
190
-
191
- <%= form_with model:@book, local:true do |f| %>
192
-
193
- <h1>New book</h1>
194
-
195
- <h4>Title</h4>
196
-
197
- <%= f.text_field :title %>
198
-
199
- <h4>Body</h4>
200
-
201
-
202
-
203
- <%= f.text_area :body %>
204
-
205
-
206
-
207
- <%= f.submit 'create book' %>
208
-
209
- <% end %>
210
-
211
-
212
-
213
- </div>
214
-
215
- **
216
-
217
- new.html.erb**
218
-
219
-
220
-
221
- <%= form_with model:@book, local:true do |f| %>
222
-
223
-
224
-
225
- <% if @book.errors.any? %>
226
-
227
- <div class = "title">
228
-
229
- <ul>
230
-
231
- <h3><span = class = "warn"><%= @book.errors.count %> error prohibited this book from being saved:</h3>
232
-
233
- <h3><% @book.errors.full_messages.each do |message| %></h3>
234
-
235
- <li><%= message %></li>
236
-
237
- <% end %>
238
-
239
- </ul>
240
-
241
- </div>
242
-
243
- <% end %>
244
-
245
-
246
-
247
- <% end %>
248
-
249
-
250
-
251
- routes.rb
252
-
253
- Rails.application.routes.draw do
254
-
255
- resources :books
256
-
257
- delete 'books/:id', to: 'books#destroy'
258
-
259
- **# For details on the DSL available within this file, see **http://guides.rubyonrails.org/routing.html
260
-
261
- root to: 'books#top'
262
-
263
- end
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
274
 
273
275
 
274
276