質問編集履歴

5

変sっゆう

2018/01/08 09:07

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,9 +1,3 @@
1
- ###現在作成中のサイトのイメージ
2
-
3
- ![イメージ説明](dcff7f135f1c0299ed298da72337251f.png)
4
-
5
-
6
-
7
1
  ###機能を実装中に以下のエラーメッセージが発生しました。
8
2
 
9
3
 

4

追加

2018/01/08 09:06

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -97,655 +97,3 @@
97
97
  メールアイコン=>edit_example_path
98
98
 
99
99
  ```
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
- ###コメントに対する追加記述
110
-
111
-
112
-
113
- ###全体共通コードapp/views/layouts/application.html.erb
114
-
115
- ```
116
-
117
- <!DOCTYPE html>
118
-
119
- <html>
120
-
121
- <head>
122
-
123
- <%= csrf_meta_tags %>
124
-
125
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
126
-
127
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
128
-
129
- </head>
130
-
131
- <body>
132
-
133
- <header class="navbar navbar-fixed-top navbar-inverse">
134
-
135
- <div class="container">
136
-
137
- <nav class="nav navbar-nav navbar-left"> <span class="glyphicon glyphicon-book">Bookers</span> </nav>
138
-
139
- <nav>
140
-
141
- <ul class="nav navbar-nav navbar-right">
142
-
143
- <% if user_signed_in? %>
144
-
145
-
146
-
147
- <li>
148
-
149
-
150
-
151
- <%= link_to user_path(current_user.id), :method => :GET do %>
152
-
153
- <i class="glyphicon glyphicon-home"></i> Home
154
-
155
- <% end %>
156
-
157
- </li>
158
-
159
- <li>
160
-
161
- <%= link_to users_path, :method => :GET do %> <i class="glyphicon glyphicon-user"></i> Users
162
-
163
- <% end %>
164
-
165
- </li>
166
-
167
- <li>
168
-
169
- <%= link_to books_path, :method => :GET do %> <i class="glyphicon glyphicon-book"></i> Books
170
-
171
- <% end %>
172
-
173
- </li>
174
-
175
- <li>
176
-
177
- <%= link_to destroy_user_session_path, :method => :delete do %> <i class="glyphicon glyphicon-log-out"></i> logout
178
-
179
- <% end %>
180
-
181
- </li>
182
-
183
- <% else %>
184
-
185
-
186
-
187
- <li>
188
-
189
- <%= link_to root_path, :method => :GET do %> <i class="glyphicon glyphicon-home"></i> Home
190
-
191
- <% end %>
192
-
193
- </li>
194
-
195
- <li>
196
-
197
- <%= link_to home_about_path, :method => :GET do %> <i class="glyphicon glyphicon-link"></i> About
198
-
199
- <% end %>
200
-
201
- </li>
202
-
203
- <li>
204
-
205
- <%= link_to new_user_registration_path, :method => :GET do %> <i class="glyphicon glyphicon-edit"></i> sign up
206
-
207
- <% end %>
208
-
209
- </li>
210
-
211
- <li>
212
-
213
- <%= link_to new_user_session_path, :method => :GET do %> <i class="glyphicon glyphicon-log-in"></i> login
214
-
215
- <% end %>
216
-
217
- </li>
218
-
219
- <% end %>
220
-
221
- </ul>
222
-
223
- </nav>
224
-
225
- </div>
226
-
227
- </header>
228
-
229
- </body>
230
-
231
- </html>
232
-
233
- ```
234
-
235
- ###部分共通コードapp/views/books/_list.html.erb
236
-
237
-
238
-
239
- ```
240
-
241
- <div class="col-lg-3" style="background-color: skyblue;">
242
-
243
- <div class="container col-lg-12" style="background-color: #fff;">
244
-
245
- <h2>User info</h2> <img class="img-responsive" src="/assets/142_refileDownloadImage.png" width="100" height="100">
246
-
247
-
248
-
249
- ここの部分のlink_toをuserのeditに飛ばしたいです。
250
-
251
- <%= link_to edit_user_path(@user), :method => :GET do %>
252
-
253
- <i class="btn btn-default glyphicon glyphicon-wrench col-lg-12"></i>
254
-
255
- <% end %>
256
-
257
-
258
-
259
-
260
-
261
- </div>
262
-
263
- </div>
264
-
265
- ```
266
-
267
- ###リンク先にしたいVIEW app/views/users/edit.html.erb
268
-
269
-
270
-
271
- ```
272
-
273
- <!DOCTYPE html>
274
-
275
- <html>
276
-
277
- <head>
278
-
279
- <title>Bookers</title>
280
-
281
- <%= csrf_meta_tags %>
282
-
283
-
284
-
285
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
286
-
287
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
288
-
289
- </head>
290
-
291
- <body>
292
-
293
-
294
-
295
- <h2>User info</h2>
296
-
297
- <p><label>Name</label><p>
298
-
299
- <p><label>Image</label><p>
300
-
301
- <p><label>Introduction</label><p>
302
-
303
-
304
-
305
-
306
-
307
-
308
-
309
- </body>
310
-
311
- </html>
312
-
313
- ```
314
-
315
-
316
-
317
- ###Usersコントローラー
318
-
319
- ```
320
-
321
- class UsersController < ApplicationController
322
-
323
- before_action :authenticate_user!
324
-
325
- def index
326
-
327
- @users = User.all
328
-
329
- end
330
-
331
-
332
-
333
- def show
334
-
335
- @user = User.find(params[:id])
336
-
337
- end
338
-
339
-
340
-
341
- def new
342
-
343
- @user=User.new
344
-
345
- end
346
-
347
-
348
-
349
- def create
350
-
351
- @user = User.new(user_params)
352
-
353
- @user.save
354
-
355
- redirect_to book_path(@book)
356
-
357
- end
358
-
359
-
360
-
361
- def edit
362
-
363
- @user = User.find(params[:id])
364
-
365
- end
366
-
367
-
368
-
369
- def update
370
-
371
- @user = User.find(params[:id])
372
-
373
- @user.update(user_params)
374
-
375
- redirect_to book_path(@book)
376
-
377
- end
378
-
379
-
380
-
381
- def destroy
382
-
383
- @user=User.find(params[:id])
384
-
385
- @user.destroy
386
-
387
- redirect_to books_path
388
-
389
- end
390
-
391
- private
392
-
393
- def user_params
394
-
395
- params.require(:user).permit(:title, :body)
396
-
397
- end
398
-
399
- end
400
-
401
- ```
402
-
403
- ###Booksコントローラー
404
-
405
- ```
406
-
407
- class BooksController < ApplicationController
408
-
409
- before_action :authenticate_user!
410
-
411
- def index
412
-
413
- @books = Book.all
414
-
415
- end
416
-
417
-
418
-
419
- def show
420
-
421
- @book = Book.find(params[:id])
422
-
423
- end
424
-
425
-
426
-
427
- def new
428
-
429
- @book=Book.new
430
-
431
- end
432
-
433
-
434
-
435
- def create
436
-
437
- @book = Book.new(book_params)
438
-
439
- @book.save
440
-
441
- redirect_to book_path(@book.id)
442
-
443
- end
444
-
445
-
446
-
447
- def edit
448
-
449
- @book = Book.find(params[:id])
450
-
451
- end
452
-
453
-
454
-
455
- def update
456
-
457
- @book = Book.find(params[:id])
458
-
459
- @book.update(book_params)
460
-
461
- redirect_to book_path(@book.id)
462
-
463
- end
464
-
465
-
466
-
467
- def destroy
468
-
469
- @book=Book.find(params[:id])
470
-
471
- @book.destroy
472
-
473
- redirect_to books_path
474
-
475
- end
476
-
477
- private
478
-
479
- def book_params
480
-
481
- params.require(:book).permit(:title, :body)
482
-
483
- end
484
-
485
- end
486
-
487
- ```
488
-
489
-
490
-
491
- ###ルーティング
492
-
493
- ```
494
-
495
- devise_for :users
496
-
497
- resources :books
498
-
499
- resources :users
500
-
501
- resources :users, only: [:show]
502
-
503
- ```
504
-
505
-
506
-
507
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
508
-
509
- app/views/books/index.html.erb
510
-
511
- ```
512
-
513
- <!DOCTYPE html>
514
-
515
- <html>
516
-
517
- <head>
518
-
519
- <%= csrf_meta_tags %>
520
-
521
-
522
-
523
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
524
-
525
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
526
-
527
- </head>
528
-
529
-
530
-
531
- <div class="body">
532
-
533
- <div class="container">
534
-
535
- <p id="notice"></p>
536
-
537
- <div class="row">
538
-
539
-
540
-
541
- 下記のコードで部分共通として呼び出しています
542
-
543
- <%= render 'books/list' %>
544
-
545
-
546
-
547
-
548
-
549
- </div>
550
-
551
- </div>
552
-
553
- </div>
554
-
555
- </html>
556
-
557
- ```
558
-
559
-
560
-
561
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
562
-
563
- app/views/books/show.html.erb
564
-
565
- ```
566
-
567
- <!DOCTYPE html>
568
-
569
- <html>
570
-
571
- <head>
572
-
573
- <%= csrf_meta_tags %>
574
-
575
-
576
-
577
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
578
-
579
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
580
-
581
- </head>
582
-
583
-
584
-
585
- <div class="body">
586
-
587
- <div class="container">
588
-
589
- <p id="notice"></p>
590
-
591
- <div class="row">
592
-
593
-
594
-
595
- 下記のコードで部分共通として呼び出しています
596
-
597
- <%= render 'books/list' %>
598
-
599
-
600
-
601
- </div>
602
-
603
- </div>
604
-
605
- </div>
606
-
607
- </html>
608
-
609
- ```
610
-
611
-
612
-
613
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
614
-
615
- app/views/users/index.html.erb
616
-
617
- ```
618
-
619
- <!DOCTYPE html>
620
-
621
- <html>
622
-
623
- <head>
624
-
625
- <%= csrf_meta_tags %>
626
-
627
-
628
-
629
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
630
-
631
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
632
-
633
- </head>
634
-
635
- <div class="body">
636
-
637
- <div class="container">
638
-
639
- <p id="notice"></p>
640
-
641
- <div class="row">
642
-
643
-
644
-
645
- 下記のコードで部分共通として呼び出しています
646
-
647
- <%= render 'books/list' %>
648
-
649
-
650
-
651
- </div>
652
-
653
- </div>
654
-
655
- </div>
656
-
657
- </html>
658
-
659
- ```
660
-
661
-
662
-
663
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
664
-
665
- app/views/users/show.html.erb
666
-
667
- ```
668
-
669
- <!DOCTYPE html>
670
-
671
- <html>
672
-
673
- <head>
674
-
675
- <%= csrf_meta_tags %>
676
-
677
-
678
-
679
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
680
-
681
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
682
-
683
- </head>
684
-
685
- <div class="body">
686
-
687
- <div class="container">
688
-
689
- <p id="notice"></p>
690
-
691
- <div class="row">
692
-
693
-
694
-
695
- 下記のコードで部分共通として呼び出しています
696
-
697
- <%= render 'books/list' %>
698
-
699
-
700
-
701
- </div>
702
-
703
- </div>
704
-
705
- </div>
706
-
707
- </html>
708
-
709
- ```
710
-
711
-
712
-
713
- ###リンク先のページ
714
-
715
- app/views/users/edit.html.erb
716
-
717
- ```
718
-
719
- <!DOCTYPE html>
720
-
721
- <html>
722
-
723
- <head>
724
-
725
- <%= csrf_meta_tags %>
726
-
727
-
728
-
729
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
730
-
731
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
732
-
733
- </head>
734
-
735
- <body>
736
-
737
-
738
-
739
- <h2>User info</h2>
740
-
741
- <p><label>Name</label><p>
742
-
743
- <p><label>text</label><p>
744
-
745
- <p><label>email</label><p>
746
-
747
- </body>
748
-
749
- </html>
750
-
751
- ```

3

追加

2018/01/08 04:13

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -100,15 +100,231 @@
100
100
 
101
101
 
102
102
 
103
+
104
+
105
+
106
+
107
+
108
+
103
- ###sampleのcontroller記述
109
+ ###コメントに対する追加記述
110
+
111
+
112
+
104
-
113
+ ###全体共通コードapp/views/layouts/application.html.erb
114
+
105
- ```
115
+ ```
116
+
106
-
117
+ <!DOCTYPE html>
118
+
119
+ <html>
120
+
121
+ <head>
122
+
123
+ <%= csrf_meta_tags %>
124
+
125
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
126
+
127
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
128
+
129
+ </head>
130
+
131
+ <body>
132
+
133
+ <header class="navbar navbar-fixed-top navbar-inverse">
134
+
135
+ <div class="container">
136
+
137
+ <nav class="nav navbar-nav navbar-left"> <span class="glyphicon glyphicon-book">Bookers</span> </nav>
138
+
139
+ <nav>
140
+
141
+ <ul class="nav navbar-nav navbar-right">
142
+
143
+ <% if user_signed_in? %>
144
+
145
+
146
+
147
+ <li>
148
+
149
+
150
+
151
+ <%= link_to user_path(current_user.id), :method => :GET do %>
152
+
153
+ <i class="glyphicon glyphicon-home"></i> Home
154
+
155
+ <% end %>
156
+
157
+ </li>
158
+
159
+ <li>
160
+
161
+ <%= link_to users_path, :method => :GET do %> <i class="glyphicon glyphicon-user"></i> Users
162
+
163
+ <% end %>
164
+
165
+ </li>
166
+
167
+ <li>
168
+
169
+ <%= link_to books_path, :method => :GET do %> <i class="glyphicon glyphicon-book"></i> Books
170
+
171
+ <% end %>
172
+
173
+ </li>
174
+
175
+ <li>
176
+
177
+ <%= link_to destroy_user_session_path, :method => :delete do %> <i class="glyphicon glyphicon-log-out"></i> logout
178
+
179
+ <% end %>
180
+
181
+ </li>
182
+
183
+ <% else %>
184
+
185
+
186
+
187
+ <li>
188
+
189
+ <%= link_to root_path, :method => :GET do %> <i class="glyphicon glyphicon-home"></i> Home
190
+
191
+ <% end %>
192
+
193
+ </li>
194
+
195
+ <li>
196
+
197
+ <%= link_to home_about_path, :method => :GET do %> <i class="glyphicon glyphicon-link"></i> About
198
+
199
+ <% end %>
200
+
201
+ </li>
202
+
203
+ <li>
204
+
205
+ <%= link_to new_user_registration_path, :method => :GET do %> <i class="glyphicon glyphicon-edit"></i> sign up
206
+
207
+ <% end %>
208
+
209
+ </li>
210
+
211
+ <li>
212
+
213
+ <%= link_to new_user_session_path, :method => :GET do %> <i class="glyphicon glyphicon-log-in"></i> login
214
+
215
+ <% end %>
216
+
217
+ </li>
218
+
219
+ <% end %>
220
+
221
+ </ul>
222
+
223
+ </nav>
224
+
225
+ </div>
226
+
227
+ </header>
228
+
229
+ </body>
230
+
231
+ </html>
232
+
233
+ ```
234
+
235
+ ###部分共通コードapp/views/books/_list.html.erb
236
+
237
+
238
+
239
+ ```
240
+
241
+ <div class="col-lg-3" style="background-color: skyblue;">
242
+
243
+ <div class="container col-lg-12" style="background-color: #fff;">
244
+
245
+ <h2>User info</h2> <img class="img-responsive" src="/assets/142_refileDownloadImage.png" width="100" height="100">
246
+
247
+
248
+
249
+ ここの部分のlink_toをuserのeditに飛ばしたいです。
250
+
251
+ <%= link_to edit_user_path(@user), :method => :GET do %>
252
+
253
+ <i class="btn btn-default glyphicon glyphicon-wrench col-lg-12"></i>
254
+
255
+ <% end %>
256
+
257
+
258
+
259
+
260
+
261
+ </div>
262
+
263
+ </div>
264
+
265
+ ```
266
+
267
+ ###リンク先にしたいVIEW app/views/users/edit.html.erb
268
+
269
+
270
+
271
+ ```
272
+
273
+ <!DOCTYPE html>
274
+
275
+ <html>
276
+
277
+ <head>
278
+
279
+ <title>Bookers</title>
280
+
281
+ <%= csrf_meta_tags %>
282
+
283
+
284
+
285
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
286
+
287
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
288
+
289
+ </head>
290
+
291
+ <body>
292
+
293
+
294
+
295
+ <h2>User info</h2>
296
+
297
+ <p><label>Name</label><p>
298
+
299
+ <p><label>Image</label><p>
300
+
301
+ <p><label>Introduction</label><p>
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+ </body>
310
+
311
+ </html>
312
+
313
+ ```
314
+
315
+
316
+
317
+ ###Usersコントローラー
318
+
319
+ ```
320
+
107
- class samplesController < ApplicationController
321
+ class UsersController < ApplicationController
322
+
323
+ before_action :authenticate_user!
108
324
 
109
325
  def index
110
326
 
111
- @samples = Sample.all
327
+ @users = User.all
112
328
 
113
329
  end
114
330
 
@@ -116,7 +332,7 @@
116
332
 
117
333
  def show
118
334
 
119
- @sample = Sample.find(params[:id])
335
+ @user = User.find(params[:id])
120
336
 
121
337
  end
122
338
 
@@ -124,7 +340,7 @@
124
340
 
125
341
  def new
126
342
 
127
- @sample=Sample.new
343
+ @user=User.new
128
344
 
129
345
  end
130
346
 
@@ -132,11 +348,11 @@
132
348
 
133
349
  def create
134
350
 
135
- @sample = Sample.new(sample_params)
351
+ @user = User.new(user_params)
136
-
352
+
137
- @sample.save
353
+ @user.save
138
-
354
+
139
- redirect_to sample_path(@sample.id)
355
+ redirect_to book_path(@book)
140
356
 
141
357
  end
142
358
 
@@ -144,7 +360,7 @@
144
360
 
145
361
  def edit
146
362
 
147
- @sample = Sample.find(params[:id])
363
+ @user = User.find(params[:id])
148
364
 
149
365
  end
150
366
 
@@ -152,11 +368,11 @@
152
368
 
153
369
  def update
154
370
 
155
- @sample = Sample.find(params[:id])
371
+ @user = User.find(params[:id])
156
-
372
+
157
- @sample.update(sample_params)
373
+ @user.update(user_params)
158
-
374
+
159
- redirect_to sample_path(@sample.id)
375
+ redirect_to book_path(@book)
160
376
 
161
377
  end
162
378
 
@@ -164,19 +380,19 @@
164
380
 
165
381
  def destroy
166
382
 
167
- @sample=Sample.find(params[:id])
383
+ @user=User.find(params[:id])
168
-
384
+
169
- @sample.destroy
385
+ @user.destroy
170
-
386
+
171
- redirect_to samples_path
387
+ redirect_to books_path
172
388
 
173
389
  end
174
390
 
175
391
  private
176
392
 
177
- def sample_params
393
+ def user_params
178
-
394
+
179
- params.require(:sample).permit(:title, :body)
395
+ params.require(:user).permit(:title, :body)
180
396
 
181
397
  end
182
398
 
@@ -184,17 +400,17 @@
184
400
 
185
401
  ```
186
402
 
187
-
188
-
189
- ###exampleのcontroller記述
403
+ ###Booksコントローラー
190
-
404
+
191
- ```
405
+ ```
192
-
406
+
193
- class examplesController < ApplicationController
407
+ class BooksController < ApplicationController
408
+
409
+ before_action :authenticate_user!
194
410
 
195
411
  def index
196
412
 
197
- @examples = Example.all
413
+ @books = Book.all
198
414
 
199
415
  end
200
416
 
@@ -202,7 +418,7 @@
202
418
 
203
419
  def show
204
420
 
205
- @example = Example.find(params[:id])
421
+ @book = Book.find(params[:id])
206
422
 
207
423
  end
208
424
 
@@ -210,7 +426,7 @@
210
426
 
211
427
  def new
212
428
 
213
- @example=Example.new
429
+ @book=Book.new
214
430
 
215
431
  end
216
432
 
@@ -218,11 +434,11 @@
218
434
 
219
435
  def create
220
436
 
221
- @example = Example.new(example_params)
437
+ @book = Book.new(book_params)
222
-
438
+
223
- @example.save
439
+ @book.save
224
-
440
+
225
- redirect_to example_path(@example)
441
+ redirect_to book_path(@book.id)
226
442
 
227
443
  end
228
444
 
@@ -230,7 +446,7 @@
230
446
 
231
447
  def edit
232
448
 
233
- @example = Example.find(params[:id])
449
+ @book = Book.find(params[:id])
234
450
 
235
451
  end
236
452
 
@@ -238,11 +454,11 @@
238
454
 
239
455
  def update
240
456
 
241
- @example = Example.find(params[:id])
457
+ @book = Book.find(params[:id])
242
-
458
+
243
- @example.update(example_params)
459
+ @book.update(book_params)
244
-
460
+
245
- redirect_to example_path(@example)
461
+ redirect_to book_path(@book.id)
246
462
 
247
463
  end
248
464
 
@@ -250,19 +466,19 @@
250
466
 
251
467
  def destroy
252
468
 
253
- @example=Example.find(params[:id])
469
+ @book=Book.find(params[:id])
254
-
470
+
255
- @example.destroy
471
+ @book.destroy
256
-
472
+
257
- redirect_to examples_path
473
+ redirect_to books_path
258
474
 
259
475
  end
260
476
 
261
477
  private
262
478
 
263
- def example_params
479
+ def book_params
264
-
480
+
265
- params.require(:example).permit(:title, :body)
481
+ params.require(:book).permit(:title, :body)
266
482
 
267
483
  end
268
484
 
@@ -272,33 +488,25 @@
272
488
 
273
489
 
274
490
 
275
-
276
-
277
- ###その他の記述
491
+ ###ルーティング
278
-
492
+
279
- ```
493
+ ```
494
+
280
-
495
+ devise_for :users
496
+
281
- resources :samples
497
+ resources :books
282
-
498
+
283
- resources :examples
499
+ resources :users
284
-
500
+
285
- resources :examples, only: [:show]
501
+ resources :users, only: [:show]
286
-
502
+
287
- ```
503
+ ```
288
-
289
-
290
-
291
- **大変分かりにくいかもしれませんがよろしくおねがしいます。**
504
+
292
-
293
-
294
-
295
-
296
-
297
- ###コメントに対する追加記述
505
+
298
-
299
-
300
-
506
+
301
- ###全体共通コードapp/views/layouts/application.html.erb
507
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
508
+
509
+ app/views/books/index.html.erb
302
510
 
303
511
  ```
304
512
 
@@ -310,588 +518,234 @@
310
518
 
311
519
  <%= csrf_meta_tags %>
312
520
 
521
+
522
+
313
523
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
314
524
 
315
525
  <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
316
526
 
317
527
  </head>
318
528
 
529
+
530
+
531
+ <div class="body">
532
+
533
+ <div class="container">
534
+
535
+ <p id="notice"></p>
536
+
537
+ <div class="row">
538
+
539
+
540
+
541
+ 下記のコードで部分共通として呼び出しています
542
+
543
+ <%= render 'books/list' %>
544
+
545
+
546
+
547
+
548
+
549
+ </div>
550
+
551
+ </div>
552
+
553
+ </div>
554
+
555
+ </html>
556
+
557
+ ```
558
+
559
+
560
+
561
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
562
+
563
+ app/views/books/show.html.erb
564
+
565
+ ```
566
+
567
+ <!DOCTYPE html>
568
+
569
+ <html>
570
+
571
+ <head>
572
+
573
+ <%= csrf_meta_tags %>
574
+
575
+
576
+
577
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
578
+
579
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
580
+
581
+ </head>
582
+
583
+
584
+
585
+ <div class="body">
586
+
587
+ <div class="container">
588
+
589
+ <p id="notice"></p>
590
+
591
+ <div class="row">
592
+
593
+
594
+
595
+ 下記のコードで部分共通として呼び出しています
596
+
597
+ <%= render 'books/list' %>
598
+
599
+
600
+
601
+ </div>
602
+
603
+ </div>
604
+
605
+ </div>
606
+
607
+ </html>
608
+
609
+ ```
610
+
611
+
612
+
613
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
614
+
615
+ app/views/users/index.html.erb
616
+
617
+ ```
618
+
619
+ <!DOCTYPE html>
620
+
621
+ <html>
622
+
623
+ <head>
624
+
625
+ <%= csrf_meta_tags %>
626
+
627
+
628
+
629
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
630
+
631
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
632
+
633
+ </head>
634
+
635
+ <div class="body">
636
+
637
+ <div class="container">
638
+
639
+ <p id="notice"></p>
640
+
641
+ <div class="row">
642
+
643
+
644
+
645
+ 下記のコードで部分共通として呼び出しています
646
+
647
+ <%= render 'books/list' %>
648
+
649
+
650
+
651
+ </div>
652
+
653
+ </div>
654
+
655
+ </div>
656
+
657
+ </html>
658
+
659
+ ```
660
+
661
+
662
+
663
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
664
+
665
+ app/views/users/show.html.erb
666
+
667
+ ```
668
+
669
+ <!DOCTYPE html>
670
+
671
+ <html>
672
+
673
+ <head>
674
+
675
+ <%= csrf_meta_tags %>
676
+
677
+
678
+
679
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
680
+
681
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
682
+
683
+ </head>
684
+
685
+ <div class="body">
686
+
687
+ <div class="container">
688
+
689
+ <p id="notice"></p>
690
+
691
+ <div class="row">
692
+
693
+
694
+
695
+ 下記のコードで部分共通として呼び出しています
696
+
697
+ <%= render 'books/list' %>
698
+
699
+
700
+
701
+ </div>
702
+
703
+ </div>
704
+
705
+ </div>
706
+
707
+ </html>
708
+
709
+ ```
710
+
711
+
712
+
713
+ ###リンク先のページ
714
+
715
+ app/views/users/edit.html.erb
716
+
717
+ ```
718
+
719
+ <!DOCTYPE html>
720
+
721
+ <html>
722
+
723
+ <head>
724
+
725
+ <%= csrf_meta_tags %>
726
+
727
+
728
+
729
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
730
+
731
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
732
+
733
+ </head>
734
+
319
735
  <body>
320
736
 
321
- <header class="navbar navbar-fixed-top navbar-inverse">
737
+
322
-
323
- <div class="container">
738
+
324
-
325
- <nav class="nav navbar-nav navbar-left"> <span class="glyphicon glyphicon-book">Bookers</span> </nav>
326
-
327
- <nav>
328
-
329
- <ul class="nav navbar-nav navbar-right">
330
-
331
- <% if user_signed_in? %>
739
+ <h2>User info</h2>
332
-
333
-
334
-
740
+
335
- <li>
741
+ <p><label>Name</label><p>
336
-
337
-
338
-
742
+
339
- <%= link_to user_path(current_user.id), :method => :GET do %>
743
+ <p><label>text</label><p>
340
-
744
+
341
- <i class="glyphicon glyphicon-home"></i> Home
745
+ <p><label>email</label><p>
342
-
343
- <% end %>
344
-
345
- </li>
346
-
347
- <li>
348
-
349
- <%= link_to users_path, :method => :GET do %> <i class="glyphicon glyphicon-user"></i> Users
350
-
351
- <% end %>
352
-
353
- </li>
354
-
355
- <li>
356
-
357
- <%= link_to books_path, :method => :GET do %> <i class="glyphicon glyphicon-book"></i> Books
358
-
359
- <% end %>
360
-
361
- </li>
362
-
363
- <li>
364
-
365
- <%= link_to destroy_user_session_path, :method => :delete do %> <i class="glyphicon glyphicon-log-out"></i> logout
366
-
367
- <% end %>
368
-
369
- </li>
370
-
371
- <% else %>
372
-
373
-
374
-
375
- <li>
376
-
377
- <%= link_to root_path, :method => :GET do %> <i class="glyphicon glyphicon-home"></i> Home
378
-
379
- <% end %>
380
-
381
- </li>
382
-
383
- <li>
384
-
385
- <%= link_to home_about_path, :method => :GET do %> <i class="glyphicon glyphicon-link"></i> About
386
-
387
- <% end %>
388
-
389
- </li>
390
-
391
- <li>
392
-
393
- <%= link_to new_user_registration_path, :method => :GET do %> <i class="glyphicon glyphicon-edit"></i> sign up
394
-
395
- <% end %>
396
-
397
- </li>
398
-
399
- <li>
400
-
401
- <%= link_to new_user_session_path, :method => :GET do %> <i class="glyphicon glyphicon-log-in"></i> login
402
-
403
- <% end %>
404
-
405
- </li>
406
-
407
- <% end %>
408
-
409
- </ul>
410
-
411
- </nav>
412
-
413
- </div>
414
-
415
- </header>
416
746
 
417
747
  </body>
418
748
 
419
749
  </html>
420
750
 
421
751
  ```
422
-
423
- ###部分共通コードapp/views/books/_list.html.erb
424
-
425
-
426
-
427
- ```
428
-
429
- <div class="col-lg-3" style="background-color: skyblue;">
430
-
431
- <div class="container col-lg-12" style="background-color: #fff;">
432
-
433
- <h2>User info</h2> <img class="img-responsive" src="/assets/142_refileDownloadImage.png" width="100" height="100">
434
-
435
-
436
-
437
- ここの部分のlink_toをuserのeditに飛ばしたいです。
438
-
439
- <%= link_to edit_user_path(@user), :method => :GET do %>
440
-
441
- <i class="btn btn-default glyphicon glyphicon-wrench col-lg-12"></i>
442
-
443
- <% end %>
444
-
445
-
446
-
447
-
448
-
449
- </div>
450
-
451
- </div>
452
-
453
- ```
454
-
455
- ###リンク先にしたいVIEW app/views/users/edit.html.erb
456
-
457
-
458
-
459
- ```
460
-
461
- <!DOCTYPE html>
462
-
463
- <html>
464
-
465
- <head>
466
-
467
- <title>Bookers</title>
468
-
469
- <%= csrf_meta_tags %>
470
-
471
-
472
-
473
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
474
-
475
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
476
-
477
- </head>
478
-
479
- <body>
480
-
481
-
482
-
483
- <h2>User info</h2>
484
-
485
- <p><label>Name</label><p>
486
-
487
- <p><label>Image</label><p>
488
-
489
- <p><label>Introduction</label><p>
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
- </body>
498
-
499
- </html>
500
-
501
- ```
502
-
503
-
504
-
505
- ###Usersコントローラー
506
-
507
- ```
508
-
509
- class UsersController < ApplicationController
510
-
511
- before_action :authenticate_user!
512
-
513
- def index
514
-
515
- @users = User.all
516
-
517
- end
518
-
519
-
520
-
521
- def show
522
-
523
- @user = User.find(params[:id])
524
-
525
- end
526
-
527
-
528
-
529
- def new
530
-
531
- @user=User.new
532
-
533
- end
534
-
535
-
536
-
537
- def create
538
-
539
- @user = User.new(user_params)
540
-
541
- @user.save
542
-
543
- redirect_to book_path(@book)
544
-
545
- end
546
-
547
-
548
-
549
- def edit
550
-
551
- @user = User.find(params[:id])
552
-
553
- end
554
-
555
-
556
-
557
- def update
558
-
559
- @user = User.find(params[:id])
560
-
561
- @user.update(user_params)
562
-
563
- redirect_to book_path(@book)
564
-
565
- end
566
-
567
-
568
-
569
- def destroy
570
-
571
- @user=User.find(params[:id])
572
-
573
- @user.destroy
574
-
575
- redirect_to books_path
576
-
577
- end
578
-
579
- private
580
-
581
- def user_params
582
-
583
- params.require(:user).permit(:title, :body)
584
-
585
- end
586
-
587
- end
588
-
589
- ```
590
-
591
- ###Booksコントローラー
592
-
593
- ```
594
-
595
- class BooksController < ApplicationController
596
-
597
- before_action :authenticate_user!
598
-
599
- def index
600
-
601
- @books = Book.all
602
-
603
- end
604
-
605
-
606
-
607
- def show
608
-
609
- @book = Book.find(params[:id])
610
-
611
- end
612
-
613
-
614
-
615
- def new
616
-
617
- @book=Book.new
618
-
619
- end
620
-
621
-
622
-
623
- def create
624
-
625
- @book = Book.new(book_params)
626
-
627
- @book.save
628
-
629
- redirect_to book_path(@book.id)
630
-
631
- end
632
-
633
-
634
-
635
- def edit
636
-
637
- @book = Book.find(params[:id])
638
-
639
- end
640
-
641
-
642
-
643
- def update
644
-
645
- @book = Book.find(params[:id])
646
-
647
- @book.update(book_params)
648
-
649
- redirect_to book_path(@book.id)
650
-
651
- end
652
-
653
-
654
-
655
- def destroy
656
-
657
- @book=Book.find(params[:id])
658
-
659
- @book.destroy
660
-
661
- redirect_to books_path
662
-
663
- end
664
-
665
- private
666
-
667
- def book_params
668
-
669
- params.require(:book).permit(:title, :body)
670
-
671
- end
672
-
673
- end
674
-
675
- ```
676
-
677
-
678
-
679
- ###ルーティング
680
-
681
- ```
682
-
683
- devise_for :users
684
-
685
- resources :books
686
-
687
- resources :users
688
-
689
- resources :users, only: [:show]
690
-
691
- ```
692
-
693
-
694
-
695
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
696
-
697
- app/views/books/index.html.erb
698
-
699
- ```
700
-
701
- <!DOCTYPE html>
702
-
703
- <html>
704
-
705
- <head>
706
-
707
- <%= csrf_meta_tags %>
708
-
709
-
710
-
711
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
712
-
713
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
714
-
715
- </head>
716
-
717
-
718
-
719
- <div class="body">
720
-
721
- <div class="container">
722
-
723
- <p id="notice"></p>
724
-
725
- <div class="row">
726
-
727
-
728
-
729
- 下記のコードで部分共通として呼び出しています
730
-
731
- <%= render 'books/list' %>
732
-
733
-
734
-
735
-
736
-
737
- </div>
738
-
739
- </div>
740
-
741
- </div>
742
-
743
- </html>
744
-
745
- ```
746
-
747
-
748
-
749
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
750
-
751
- app/views/books/show.html.erb
752
-
753
- ```
754
-
755
- <!DOCTYPE html>
756
-
757
- <html>
758
-
759
- <head>
760
-
761
- <%= csrf_meta_tags %>
762
-
763
-
764
-
765
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
766
-
767
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
768
-
769
- </head>
770
-
771
-
772
-
773
- <div class="body">
774
-
775
- <div class="container">
776
-
777
- <p id="notice"></p>
778
-
779
- <div class="row">
780
-
781
-
782
-
783
- 下記のコードで部分共通として呼び出しています
784
-
785
- <%= render 'books/list' %>
786
-
787
-
788
-
789
- </div>
790
-
791
- </div>
792
-
793
- </div>
794
-
795
- </html>
796
-
797
- ```
798
-
799
-
800
-
801
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
802
-
803
- app/views/users/index.html.erb
804
-
805
- ```
806
-
807
- <!DOCTYPE html>
808
-
809
- <html>
810
-
811
- <head>
812
-
813
- <%= csrf_meta_tags %>
814
-
815
-
816
-
817
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
818
-
819
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
820
-
821
- </head>
822
-
823
- <div class="body">
824
-
825
- <div class="container">
826
-
827
- <p id="notice"></p>
828
-
829
- <div class="row">
830
-
831
-
832
-
833
- 下記のコードで部分共通として呼び出しています
834
-
835
- <%= render 'books/list' %>
836
-
837
-
838
-
839
- </div>
840
-
841
- </div>
842
-
843
- </div>
844
-
845
- </html>
846
-
847
- ```
848
-
849
-
850
-
851
- ###部分共通コードapp/views/books/_list.html.erbを使っている場所
852
-
853
- app/views/users/show.html.erb
854
-
855
- ```
856
-
857
- <!DOCTYPE html>
858
-
859
- <html>
860
-
861
- <head>
862
-
863
- <%= csrf_meta_tags %>
864
-
865
-
866
-
867
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
868
-
869
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
870
-
871
- </head>
872
-
873
- <div class="body">
874
-
875
- <div class="container">
876
-
877
- <p id="notice"></p>
878
-
879
- <div class="row">
880
-
881
-
882
-
883
- 下記のコードで部分共通として呼び出しています
884
-
885
- <%= render 'books/list' %>
886
-
887
-
888
-
889
- </div>
890
-
891
- </div>
892
-
893
- </div>
894
-
895
- </html>
896
-
897
- ```

2

追加

2018/01/07 04:00

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -689,3 +689,209 @@
689
689
  resources :users, only: [:show]
690
690
 
691
691
  ```
692
+
693
+
694
+
695
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
696
+
697
+ app/views/books/index.html.erb
698
+
699
+ ```
700
+
701
+ <!DOCTYPE html>
702
+
703
+ <html>
704
+
705
+ <head>
706
+
707
+ <%= csrf_meta_tags %>
708
+
709
+
710
+
711
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
712
+
713
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
714
+
715
+ </head>
716
+
717
+
718
+
719
+ <div class="body">
720
+
721
+ <div class="container">
722
+
723
+ <p id="notice"></p>
724
+
725
+ <div class="row">
726
+
727
+
728
+
729
+ 下記のコードで部分共通として呼び出しています
730
+
731
+ <%= render 'books/list' %>
732
+
733
+
734
+
735
+
736
+
737
+ </div>
738
+
739
+ </div>
740
+
741
+ </div>
742
+
743
+ </html>
744
+
745
+ ```
746
+
747
+
748
+
749
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
750
+
751
+ app/views/books/show.html.erb
752
+
753
+ ```
754
+
755
+ <!DOCTYPE html>
756
+
757
+ <html>
758
+
759
+ <head>
760
+
761
+ <%= csrf_meta_tags %>
762
+
763
+
764
+
765
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
766
+
767
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
768
+
769
+ </head>
770
+
771
+
772
+
773
+ <div class="body">
774
+
775
+ <div class="container">
776
+
777
+ <p id="notice"></p>
778
+
779
+ <div class="row">
780
+
781
+
782
+
783
+ 下記のコードで部分共通として呼び出しています
784
+
785
+ <%= render 'books/list' %>
786
+
787
+
788
+
789
+ </div>
790
+
791
+ </div>
792
+
793
+ </div>
794
+
795
+ </html>
796
+
797
+ ```
798
+
799
+
800
+
801
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
802
+
803
+ app/views/users/index.html.erb
804
+
805
+ ```
806
+
807
+ <!DOCTYPE html>
808
+
809
+ <html>
810
+
811
+ <head>
812
+
813
+ <%= csrf_meta_tags %>
814
+
815
+
816
+
817
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
818
+
819
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
820
+
821
+ </head>
822
+
823
+ <div class="body">
824
+
825
+ <div class="container">
826
+
827
+ <p id="notice"></p>
828
+
829
+ <div class="row">
830
+
831
+
832
+
833
+ 下記のコードで部分共通として呼び出しています
834
+
835
+ <%= render 'books/list' %>
836
+
837
+
838
+
839
+ </div>
840
+
841
+ </div>
842
+
843
+ </div>
844
+
845
+ </html>
846
+
847
+ ```
848
+
849
+
850
+
851
+ ###部分共通コードapp/views/books/_list.html.erbを使っている場所
852
+
853
+ app/views/users/show.html.erb
854
+
855
+ ```
856
+
857
+ <!DOCTYPE html>
858
+
859
+ <html>
860
+
861
+ <head>
862
+
863
+ <%= csrf_meta_tags %>
864
+
865
+
866
+
867
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
868
+
869
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
870
+
871
+ </head>
872
+
873
+ <div class="body">
874
+
875
+ <div class="container">
876
+
877
+ <p id="notice"></p>
878
+
879
+ <div class="row">
880
+
881
+
882
+
883
+ 下記のコードで部分共通として呼び出しています
884
+
885
+ <%= render 'books/list' %>
886
+
887
+
888
+
889
+ </div>
890
+
891
+ </div>
892
+
893
+ </div>
894
+
895
+ </html>
896
+
897
+ ```

1

編集

2018/01/07 03:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -289,3 +289,403 @@
289
289
 
290
290
 
291
291
  **大変分かりにくいかもしれませんがよろしくおねがしいます。**
292
+
293
+
294
+
295
+
296
+
297
+ ###コメントに対する追加記述
298
+
299
+
300
+
301
+ ###全体共通コードapp/views/layouts/application.html.erb
302
+
303
+ ```
304
+
305
+ <!DOCTYPE html>
306
+
307
+ <html>
308
+
309
+ <head>
310
+
311
+ <%= csrf_meta_tags %>
312
+
313
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
314
+
315
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
316
+
317
+ </head>
318
+
319
+ <body>
320
+
321
+ <header class="navbar navbar-fixed-top navbar-inverse">
322
+
323
+ <div class="container">
324
+
325
+ <nav class="nav navbar-nav navbar-left"> <span class="glyphicon glyphicon-book">Bookers</span> </nav>
326
+
327
+ <nav>
328
+
329
+ <ul class="nav navbar-nav navbar-right">
330
+
331
+ <% if user_signed_in? %>
332
+
333
+
334
+
335
+ <li>
336
+
337
+
338
+
339
+ <%= link_to user_path(current_user.id), :method => :GET do %>
340
+
341
+ <i class="glyphicon glyphicon-home"></i> Home
342
+
343
+ <% end %>
344
+
345
+ </li>
346
+
347
+ <li>
348
+
349
+ <%= link_to users_path, :method => :GET do %> <i class="glyphicon glyphicon-user"></i> Users
350
+
351
+ <% end %>
352
+
353
+ </li>
354
+
355
+ <li>
356
+
357
+ <%= link_to books_path, :method => :GET do %> <i class="glyphicon glyphicon-book"></i> Books
358
+
359
+ <% end %>
360
+
361
+ </li>
362
+
363
+ <li>
364
+
365
+ <%= link_to destroy_user_session_path, :method => :delete do %> <i class="glyphicon glyphicon-log-out"></i> logout
366
+
367
+ <% end %>
368
+
369
+ </li>
370
+
371
+ <% else %>
372
+
373
+
374
+
375
+ <li>
376
+
377
+ <%= link_to root_path, :method => :GET do %> <i class="glyphicon glyphicon-home"></i> Home
378
+
379
+ <% end %>
380
+
381
+ </li>
382
+
383
+ <li>
384
+
385
+ <%= link_to home_about_path, :method => :GET do %> <i class="glyphicon glyphicon-link"></i> About
386
+
387
+ <% end %>
388
+
389
+ </li>
390
+
391
+ <li>
392
+
393
+ <%= link_to new_user_registration_path, :method => :GET do %> <i class="glyphicon glyphicon-edit"></i> sign up
394
+
395
+ <% end %>
396
+
397
+ </li>
398
+
399
+ <li>
400
+
401
+ <%= link_to new_user_session_path, :method => :GET do %> <i class="glyphicon glyphicon-log-in"></i> login
402
+
403
+ <% end %>
404
+
405
+ </li>
406
+
407
+ <% end %>
408
+
409
+ </ul>
410
+
411
+ </nav>
412
+
413
+ </div>
414
+
415
+ </header>
416
+
417
+ </body>
418
+
419
+ </html>
420
+
421
+ ```
422
+
423
+ ###部分共通コードapp/views/books/_list.html.erb
424
+
425
+
426
+
427
+ ```
428
+
429
+ <div class="col-lg-3" style="background-color: skyblue;">
430
+
431
+ <div class="container col-lg-12" style="background-color: #fff;">
432
+
433
+ <h2>User info</h2> <img class="img-responsive" src="/assets/142_refileDownloadImage.png" width="100" height="100">
434
+
435
+
436
+
437
+ ここの部分のlink_toをuserのeditに飛ばしたいです。
438
+
439
+ <%= link_to edit_user_path(@user), :method => :GET do %>
440
+
441
+ <i class="btn btn-default glyphicon glyphicon-wrench col-lg-12"></i>
442
+
443
+ <% end %>
444
+
445
+
446
+
447
+
448
+
449
+ </div>
450
+
451
+ </div>
452
+
453
+ ```
454
+
455
+ ###リンク先にしたいVIEW app/views/users/edit.html.erb
456
+
457
+
458
+
459
+ ```
460
+
461
+ <!DOCTYPE html>
462
+
463
+ <html>
464
+
465
+ <head>
466
+
467
+ <title>Bookers</title>
468
+
469
+ <%= csrf_meta_tags %>
470
+
471
+
472
+
473
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
474
+
475
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
476
+
477
+ </head>
478
+
479
+ <body>
480
+
481
+
482
+
483
+ <h2>User info</h2>
484
+
485
+ <p><label>Name</label><p>
486
+
487
+ <p><label>Image</label><p>
488
+
489
+ <p><label>Introduction</label><p>
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ </body>
498
+
499
+ </html>
500
+
501
+ ```
502
+
503
+
504
+
505
+ ###Usersコントローラー
506
+
507
+ ```
508
+
509
+ class UsersController < ApplicationController
510
+
511
+ before_action :authenticate_user!
512
+
513
+ def index
514
+
515
+ @users = User.all
516
+
517
+ end
518
+
519
+
520
+
521
+ def show
522
+
523
+ @user = User.find(params[:id])
524
+
525
+ end
526
+
527
+
528
+
529
+ def new
530
+
531
+ @user=User.new
532
+
533
+ end
534
+
535
+
536
+
537
+ def create
538
+
539
+ @user = User.new(user_params)
540
+
541
+ @user.save
542
+
543
+ redirect_to book_path(@book)
544
+
545
+ end
546
+
547
+
548
+
549
+ def edit
550
+
551
+ @user = User.find(params[:id])
552
+
553
+ end
554
+
555
+
556
+
557
+ def update
558
+
559
+ @user = User.find(params[:id])
560
+
561
+ @user.update(user_params)
562
+
563
+ redirect_to book_path(@book)
564
+
565
+ end
566
+
567
+
568
+
569
+ def destroy
570
+
571
+ @user=User.find(params[:id])
572
+
573
+ @user.destroy
574
+
575
+ redirect_to books_path
576
+
577
+ end
578
+
579
+ private
580
+
581
+ def user_params
582
+
583
+ params.require(:user).permit(:title, :body)
584
+
585
+ end
586
+
587
+ end
588
+
589
+ ```
590
+
591
+ ###Booksコントローラー
592
+
593
+ ```
594
+
595
+ class BooksController < ApplicationController
596
+
597
+ before_action :authenticate_user!
598
+
599
+ def index
600
+
601
+ @books = Book.all
602
+
603
+ end
604
+
605
+
606
+
607
+ def show
608
+
609
+ @book = Book.find(params[:id])
610
+
611
+ end
612
+
613
+
614
+
615
+ def new
616
+
617
+ @book=Book.new
618
+
619
+ end
620
+
621
+
622
+
623
+ def create
624
+
625
+ @book = Book.new(book_params)
626
+
627
+ @book.save
628
+
629
+ redirect_to book_path(@book.id)
630
+
631
+ end
632
+
633
+
634
+
635
+ def edit
636
+
637
+ @book = Book.find(params[:id])
638
+
639
+ end
640
+
641
+
642
+
643
+ def update
644
+
645
+ @book = Book.find(params[:id])
646
+
647
+ @book.update(book_params)
648
+
649
+ redirect_to book_path(@book.id)
650
+
651
+ end
652
+
653
+
654
+
655
+ def destroy
656
+
657
+ @book=Book.find(params[:id])
658
+
659
+ @book.destroy
660
+
661
+ redirect_to books_path
662
+
663
+ end
664
+
665
+ private
666
+
667
+ def book_params
668
+
669
+ params.require(:book).permit(:title, :body)
670
+
671
+ end
672
+
673
+ end
674
+
675
+ ```
676
+
677
+
678
+
679
+ ###ルーティング
680
+
681
+ ```
682
+
683
+ devise_for :users
684
+
685
+ resources :books
686
+
687
+ resources :users
688
+
689
+ resources :users, only: [:show]
690
+
691
+ ```