From e0514c83d95ee59dcf3d1fc1a069ec38119b68ea Mon Sep 17 00:00:00 2001 From: azu-68 Date: Tue, 14 Mar 2023 22:14:06 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=81=8C=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?sessions=5Fcontroller.rb=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/sessions_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 26b5e71..3abc54b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -3,8 +3,8 @@ class SessionsController < ApplicationController def new; end def create - user = User.find_by(email: params[:email]) - if user&.authenticate(params[:password]) + user = User.find_by(email: params[:session][:email]) + if user&.authenticate(params[:session][:password]) session[:user_id] = user.id redirect_to posts_path, notice: 'ログインしました' else From e0f40ab95ebb4dc5b2bb82803846a07ec4986e7e Mon Sep 17 00:00:00 2001 From: azu-68 Date: Tue, 14 Mar 2023 22:16:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=81=AE=E6=96=B0?= =?UTF-8?q?=E8=A6=8F=E4=BD=9C=E6=88=90=E3=81=8C=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=ABapplication=5Fcontroller.rb=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56fccf9..fc6f22c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,8 @@ class ApplicationController < ActionController::Base def current_user - @current_user ||= User.find_by(id: session[:id]) if session[:user_id].present? + @current_user ||= User.find_by(id: session[:user_id]) if session[:user_id].present? + end helper_method :current_user From 256e482ae0f48f529e8e11dd3edb345d18610420 Mon Sep 17 00:00:00 2001 From: azu-68 Date: Tue, 14 Mar 2023 22:25:28 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Post=E3=81=AE=E6=8A=95=E7=A8=BF=E3=82=92?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=8C?= =?UTF-8?q?=5Fform.html.erb=E3=80=8D=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index f943aad..16c95aa 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -13,7 +13,7 @@
<%= form.label :title, style: "display: block" %> - <%= form.text_field :titlee %> + <%= form.text_field :title %>