質問編集履歴
6
ルートとコントローラーの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -373,3 +373,127 @@
|
|
373
373
|
## eiyou.jpgに変更後
|
374
374
|
|
375
375
|

|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
### route.rb
|
380
|
+
|
381
|
+
```
|
382
|
+
|
383
|
+
Rails.application.routes.draw do
|
384
|
+
|
385
|
+
get 'welcome/index'
|
386
|
+
|
387
|
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
388
|
+
|
389
|
+
resources :books
|
390
|
+
|
391
|
+
root 'welcome#index'
|
392
|
+
|
393
|
+
end
|
394
|
+
|
395
|
+
```
|
396
|
+
|
397
|
+
### books_controller.rb
|
398
|
+
|
399
|
+
```
|
400
|
+
|
401
|
+
class BooksController < ApplicationController#to do index アクションを作る
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
def index
|
406
|
+
|
407
|
+
@books = Book.all
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
def show
|
414
|
+
|
415
|
+
@book = Book.find(params[:id])
|
416
|
+
|
417
|
+
end
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
def new
|
422
|
+
|
423
|
+
@book = Book.new
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
def edit
|
430
|
+
|
431
|
+
@book = Book.find(params[:id])
|
432
|
+
|
433
|
+
end
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
def create
|
438
|
+
|
439
|
+
@book = Book.new(book_params)
|
440
|
+
|
441
|
+
if @book.save
|
442
|
+
|
443
|
+
redirect_to @book
|
444
|
+
|
445
|
+
else
|
446
|
+
|
447
|
+
render :new
|
448
|
+
|
449
|
+
end
|
450
|
+
|
451
|
+
end
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
def update
|
456
|
+
|
457
|
+
@book = Book.find(params[:id])
|
458
|
+
|
459
|
+
if @book.update(book_params)
|
460
|
+
|
461
|
+
redirect_to @book
|
462
|
+
|
463
|
+
else
|
464
|
+
|
465
|
+
render :edit
|
466
|
+
|
467
|
+
end
|
468
|
+
|
469
|
+
end
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
def destroy
|
474
|
+
|
475
|
+
@book = Book.find(params[:id])
|
476
|
+
|
477
|
+
@book.destroy!
|
478
|
+
|
479
|
+
redirect_to books_path
|
480
|
+
|
481
|
+
end
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
private
|
490
|
+
|
491
|
+
def book_params
|
492
|
+
|
493
|
+
params.require(:book).permit(:title, :text)
|
494
|
+
|
495
|
+
end
|
496
|
+
|
497
|
+
end
|
498
|
+
|
499
|
+
```
|
5
eiyouに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -371,3 +371,5 @@
|
|
371
371
|
|
372
372
|
|
373
373
|
## eiyou.jpgに変更後
|
374
|
+
|
375
|
+

|
4
eiyouに修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -365,3 +365,9 @@
|
|
365
365
|
### サーバーで表示されたメッセージ
|
366
366
|
|
367
367
|

|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
## eiyou.jpgに変更後
|
3
メッセージ追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -359,3 +359,9 @@
|
|
359
359
|
}
|
360
360
|
|
361
361
|
```
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
### サーバーで表示されたメッセージ
|
366
|
+
|
367
|
+

|
2
jpgの追加、scssの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -301,3 +301,61 @@
|
|
301
301
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
302
302
|
|
303
303
|
```
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
### imageに追加した内容,jpg
|
308
|
+
|
309
|
+

|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
### application.scss
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
/*
|
322
|
+
|
323
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
324
|
+
|
325
|
+
* listed below.
|
326
|
+
|
327
|
+
*
|
328
|
+
|
329
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
330
|
+
|
331
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
332
|
+
|
333
|
+
*
|
334
|
+
|
335
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
336
|
+
|
337
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
338
|
+
|
339
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
340
|
+
|
341
|
+
* It is generally better to create a new file per style scope.
|
342
|
+
|
343
|
+
*
|
344
|
+
|
345
|
+
*= require_tree .
|
346
|
+
|
347
|
+
*= require_self
|
348
|
+
|
349
|
+
*/
|
350
|
+
|
351
|
+
@import "bootstrap";
|
352
|
+
|
353
|
+
.jumbotron {
|
354
|
+
|
355
|
+
background-image: image-url("栄養画像参考.jpg");
|
356
|
+
|
357
|
+
background-size: cover;
|
358
|
+
|
359
|
+
}
|
360
|
+
|
361
|
+
```
|
1
scssファイルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -235,3 +235,69 @@
|
|
235
235
|
gem 'jquery-rails'
|
236
236
|
|
237
237
|
```
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
### application.scss
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
/*
|
246
|
+
|
247
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
248
|
+
|
249
|
+
* listed below.
|
250
|
+
|
251
|
+
*
|
252
|
+
|
253
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
254
|
+
|
255
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
256
|
+
|
257
|
+
*
|
258
|
+
|
259
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
260
|
+
|
261
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
262
|
+
|
263
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
264
|
+
|
265
|
+
* It is generally better to create a new file per style scope.
|
266
|
+
|
267
|
+
*
|
268
|
+
|
269
|
+
*= require_tree .
|
270
|
+
|
271
|
+
*= require_self
|
272
|
+
|
273
|
+
*/
|
274
|
+
|
275
|
+
@import "bootstrap";
|
276
|
+
|
277
|
+
```
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
### books.scss
|
282
|
+
|
283
|
+
```
|
284
|
+
|
285
|
+
// Place all the styles related to the books controller here.
|
286
|
+
|
287
|
+
// They will automatically be included in application.css.
|
288
|
+
|
289
|
+
// You can use Sass (SCSS) here: http://sass-lang.com/
|
290
|
+
|
291
|
+
```
|
292
|
+
|
293
|
+
### welcome.scss
|
294
|
+
|
295
|
+
```
|
296
|
+
|
297
|
+
// Place all the styles related to the welcome controller here.
|
298
|
+
|
299
|
+
// They will automatically be included in application.css.
|
300
|
+
|
301
|
+
// You can use Sass (SCSS) here: http://sass-lang.com/
|
302
|
+
|
303
|
+
```
|