質問編集履歴

2

ソースコードの追加

2021/06/17 02:38

投稿

takuma1229
takuma1229

スコア11

test CHANGED
File without changes
test CHANGED
@@ -496,37 +496,7 @@
496
496
 
497
497
 
498
498
 
499
- <%= f.label :purpose, "Purpose of Learning | 学習目的" %>
499
+
500
-
501
- <%= f.select :purpose, [["Business | 仕事", "Business | 仕事"], ["School Classes | 学校の授業", "School Classes | 学校の授業"],
502
-
503
- ["Entrance Exam | 受験","Entrance Exam | 受験"], ["Trip | 旅行","Trip | 旅行"], ["Want to talk with Foreingers | 外国の人と話したい","Want to talk with Foreingers | 外国の人と話したい"],
504
-
505
- ["Qualifying Exam | 資格試験","Qualifying Exam | 資格試験"], ["Hobby | 趣味","Hobby | 趣味"], ["Other | その他", "Other | その他"]], include_blank: "Please select.", class:"form-control" %>
506
-
507
-
508
-
509
- <%= f.label :self_introduction, "Self Introduction | 自己紹介" %>
510
-
511
- <%= f.text_area :self_introduction, class: 'form-control self-intro', placeholder: "It is recommended that you write in simple English. 英語で書くことをお勧めします。簡単な文でも問題ありません。" %>
512
-
513
-
514
-
515
- <%= f.label :sns_1, "URL of Your SNS 1 (optional) | SNSリンク1(任意)" %>
516
-
517
- <%= f.text_field :sns_1, class: 'form-control' %>
518
-
519
-
520
-
521
- <%= f.label :sns_2, "URL of Your SNS 2 (optional) | SNSリンク2(任意)" %>
522
-
523
- <%= f.text_field :sns_2, class: 'form-control' %>
524
-
525
-
526
-
527
- <%= f.label :sns_3, "URL of Your SNS 3 (optional) | SNSリンク3(任意)" %>
528
-
529
- <%= f.text_field :sns_3, class: 'form-control' %>
530
500
 
531
501
 
532
502
 
@@ -550,6 +520,104 @@
550
520
 
551
521
 
552
522
 
523
+ ```ruby
524
+
525
+ [sessions_helper.rb]
526
+
527
+ module SessionsHelper
528
+
529
+
530
+
531
+ def log_in(user)
532
+
533
+ session[:user_id] = user.id
534
+
535
+ end
536
+
537
+
538
+
539
+ def remember(user)
540
+
541
+ user.remember
542
+
543
+ cookies.permanent.signed[:user_id] = user.id
544
+
545
+ cookies.permanent[:remember_token] = user.remember_token
546
+
547
+ end
548
+
549
+
550
+
551
+ def current_user
552
+
553
+ if(user_id = session[:user_id])
554
+
555
+ @current_user ||= User.find_by(id: user_id)
556
+
557
+ elsif(user_id = cookies.signed[:user_id])
558
+
559
+ user = User.find_by(id: user_id)
560
+
561
+ if user && user.authenticated?(cookies[:remember_token])
562
+
563
+ log_in user
564
+
565
+ @current_user = user
566
+
567
+ end
568
+
569
+ end
570
+
571
+ end
572
+
573
+
574
+
575
+ def logged_in?
576
+
577
+ !current_user.nil?
578
+
579
+ end
580
+
581
+
582
+
583
+ def log_out
584
+
585
+ session.delete(:user_id)
586
+
587
+ @current_user = nil
588
+
589
+ end
590
+
591
+
592
+
593
+ def forget(user)
594
+
595
+ user.forget
596
+
597
+ cookies.delete(:user_id)
598
+
599
+ cookies.delete(:remember_token)
600
+
601
+ end
602
+
603
+
604
+
605
+ def log_out
606
+
607
+ forget(current_user)
608
+
609
+ session.delete(:user_id)
610
+
611
+ @current_user = nil
612
+
613
+ end
614
+
615
+ end
616
+
617
+ ```
618
+
619
+
620
+
553
621
 
554
622
 
555
623
  ### 補足情報(FW/ツールのバージョンなど)

1

ソースコードの追加

2021/06/17 02:38

投稿

takuma1229
takuma1229

スコア11

test CHANGED
File without changes
test CHANGED
@@ -350,6 +350,206 @@
350
350
 
351
351
 
352
352
 
353
+ ```html
354
+
355
+ [new.html.erb]//ユーザー新規登録のビューです
356
+
357
+ <% provide(:title, 'Sign up') %>
358
+
359
+
360
+
361
+ <div class="signup-wrapper">
362
+
363
+ <h1 class="Signup">Sign up</h1>
364
+
365
+
366
+
367
+ <div class="row signup-forms">
368
+
369
+ <div class="col-md-6 col-md-offset-3">
370
+
371
+ <%= form_with(model: @user, local: true) do |f| %>
372
+
373
+ <%= render 'shared/error_messages'%>
374
+
375
+
376
+
377
+ <%= f.label :name, "Nickname" %>
378
+
379
+ <%= f.text_field :name, class: 'form-control' %>
380
+
381
+
382
+
383
+ <%= f.label :email %>
384
+
385
+ <%= f.email_field :email, class: "form-control" %>
386
+
387
+
388
+
389
+ <%= f.label :password %>
390
+
391
+ <%= f.password_field :password, class: "form-control" %>
392
+
393
+
394
+
395
+ <%= f.label :password_confirmation, "Confirmation" %>
396
+
397
+ <%= f.password_field :password_confirmation, class: "form-control" %>
398
+
399
+
400
+
401
+ <%= f.label :image %>
402
+
403
+ <%= f.file_field :image, class: "form-control image-form" %>
404
+
405
+
406
+
407
+
408
+
409
+ <%= f.submit "Create Your Account", class: "btn btn-primary create" %>
410
+
411
+ <% end %>
412
+
413
+ </div>
414
+
415
+ </div>
416
+
417
+ </div>
418
+
419
+ ```
420
+
421
+
422
+
423
+ ```html
424
+
425
+ [details.html.erb]//detail(ユーザー詳細情報)登録画面のビューです
426
+
427
+ <% provide(:title, "user detail") %>
428
+
429
+
430
+
431
+ <div class="user-detail-wrapper">
432
+
433
+ <div class="introduction">
434
+
435
+ <h3>①Authorize your account via sent Email. | 送信されたメールからアカウント認証を行なってください。</h3>
436
+
437
+ <h3>②Let's register your user informations! | ユーザー情報を登録しましょう!<br>You can change it later. | この情報は後から修正可能です。</h3>
438
+
439
+ </div>
440
+
441
+
442
+
443
+ <div class="row user-detail-forms">
444
+
445
+ <div class="col-md-6 col-md-offset-3">
446
+
447
+ <%= form_with(model: @detail, local: true) do |f| %>
448
+
449
+
450
+
451
+
452
+
453
+ <%= f.label :mother_tongue, "Mother Tongue | 母語" %>
454
+
455
+ <%= f.select :mother_tongue, [["English", "English"], ["Japanese", "Japanese"],
456
+
457
+ ["Other","other"]], include_blank: "Please select.", class:"form-control" %>
458
+
459
+
460
+
461
+ <%= f.label :japanese_level, "Japanese Level | 日本語のレベル" %>
462
+
463
+ <%= f.select :japanese_level, [["Beginner | 初心者", "Beginner | 初心者"], ["Capable of quite basic communication | 簡単な会話ならできる", "Capable of quite basic communication | 簡単な会話ならできる"],
464
+
465
+ ["Capable of daily conversation | 日常会話ができる","Capable of daily conversation | 日常会話ができる"], ["Capable of advanced conversation | 難しい内容の会話ができる","Capable of advanced conversation | 難しい内容の会話ができる"], ["Almost native level | ネイティブとほとんど同レベル","Almost native level | ネイティブとほとんど同レベル"],
466
+
467
+ ["Native | ネイティブ","Native | ネイティブ"]], include_blank: "Please select.", class:"form-control" %>
468
+
469
+
470
+
471
+ <%= f.label :english_level, "English Level | 英語のレベル" %>
472
+
473
+ <%= f.select :english_level, [["Beginner | 初心者", "Beginner | 初心者"], ["Capable of quite basic communication | 簡単な会話ならできる", "Capable of quite basic communication | 簡単な会話ならできる"],
474
+
475
+ ["Capable of daily conversation | 日常会話ができる","Capable of daily conversation | 日常会話ができる"], ["Capable of advanced conversation | 難しい内容の会話ができる","Capable of advanced conversation | 難しい内容の会話ができる"], ["Almost native level | ネイティブとほとんど同レベル","Almost native level | ネイティブとほとんど同レベル"],
476
+
477
+ ["Native | ネイティブ","Native | ネイティブ"]], include_blank: "Please select.", class:"form-control" %>
478
+
479
+
480
+
481
+ <%= f.label :gender, "Gender(optional) | ジェンダー(任意)" %>
482
+
483
+ <%= f.select :gender, [["he/him | 男性", "he/him | 男性"], ["she/her | 女性", "she/her | 女性"],
484
+
485
+ ["they/them | その他","they/them | その他"], ["I don't want to tell | 言いたくない","I don't want to tell | 言いたくない"]], include_blank: "Please select.", class:"form-control" %>
486
+
487
+
488
+
489
+ <%= f.label :region, "Region | 地域" %>
490
+
491
+ <%= f.select :region, [["Asia | アジア", "Asia | アジア"], ["Europe |ヨーロッパ", "Europe | ヨーロッパ"],
492
+
493
+ ["Africa | アフリカ","Africa | アフリカ"], ["North/Central America | 北/中央アメリカ","North/Central America | 北/中央アメリカ"], ["South America | 南アメリカ","South America | 南アメリカ"],
494
+
495
+ ["Oceania | オセアニア","Oceania | オセアニア"], ["Other | その他","Other | その他"]], include_blank: "Please select.", class:"form-control" %>
496
+
497
+
498
+
499
+ <%= f.label :purpose, "Purpose of Learning | 学習目的" %>
500
+
501
+ <%= f.select :purpose, [["Business | 仕事", "Business | 仕事"], ["School Classes | 学校の授業", "School Classes | 学校の授業"],
502
+
503
+ ["Entrance Exam | 受験","Entrance Exam | 受験"], ["Trip | 旅行","Trip | 旅行"], ["Want to talk with Foreingers | 外国の人と話したい","Want to talk with Foreingers | 外国の人と話したい"],
504
+
505
+ ["Qualifying Exam | 資格試験","Qualifying Exam | 資格試験"], ["Hobby | 趣味","Hobby | 趣味"], ["Other | その他", "Other | その他"]], include_blank: "Please select.", class:"form-control" %>
506
+
507
+
508
+
509
+ <%= f.label :self_introduction, "Self Introduction | 自己紹介" %>
510
+
511
+ <%= f.text_area :self_introduction, class: 'form-control self-intro', placeholder: "It is recommended that you write in simple English. 英語で書くことをお勧めします。簡単な文でも問題ありません。" %>
512
+
513
+
514
+
515
+ <%= f.label :sns_1, "URL of Your SNS 1 (optional) | SNSリンク1(任意)" %>
516
+
517
+ <%= f.text_field :sns_1, class: 'form-control' %>
518
+
519
+
520
+
521
+ <%= f.label :sns_2, "URL of Your SNS 2 (optional) | SNSリンク2(任意)" %>
522
+
523
+ <%= f.text_field :sns_2, class: 'form-control' %>
524
+
525
+
526
+
527
+ <%= f.label :sns_3, "URL of Your SNS 3 (optional) | SNSリンク3(任意)" %>
528
+
529
+ <%= f.text_field :sns_3, class: 'form-control' %>
530
+
531
+
532
+
533
+ <%= f.text_field :user_id, type: "hidden", value: "#{current_user.id}" %>
534
+
535
+
536
+
537
+
538
+
539
+ <%= f.submit "Send | 送信", class: "btn btn-primary create" %>
540
+
541
+ <% end %>
542
+
543
+ </div>
544
+
545
+ </div>
546
+
547
+ </div>
548
+
549
+ ```
550
+
551
+
552
+
353
553
 
354
554
 
355
555
  ### 補足情報(FW/ツールのバージョンなど)