Skip to content

Bug fix#11

Open
wiskerpaddy wants to merge 4 commits intoDaichiSaito:bugfrom
wiskerpaddy:bug_fix
Open

Bug fix#11
wiskerpaddy wants to merge 4 commits intoDaichiSaito:bugfrom
wiskerpaddy:bug_fix

Conversation

@wiskerpaddy
Copy link
Copy Markdown

課題1~3まで対応しました。ご確認お願いします

Comment thread app/controllers/sessions_controller.rb Outdated
@@ -1,10 +1,11 @@
class SessionsController < ApplicationController

protect_from_forgery
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これいりますっけ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いりませんでした。確認漏れてました。。。消して上げなおします

@DaichiSaito
Copy link
Copy Markdown
Owner

image

せっかくなのでPRの概要をしっかり書きましょうか。
課題1〜3までそれぞれ何をやったのか、原因を書いてみましょう。

@wiskerpaddy
Copy link
Copy Markdown
Author

wiskerpaddy commented Mar 1, 2024

目的

 「プラクティス-デバッグ方法を身につける」課題1ー3の修正対応

達成条件

 「プラクティス-デバッグ方法を身につける」の期待値通りに動作すること

実装の概要

課題1「ログインができない」

原因・修正内容:配列の指定が間違っていた(userがnilになっていた)ので配列の指定を修正。

# app/controllers/sessions_controller.rb
# 修正前 
user = User.find_by(email: params[:email])
# 修正後 
user = User.find_by(email: params[:session][:email])

    

課題2「ログインしているはずなのにログイン必須の画面にアクセスできない」

原因・修正内容:User.find_by()で指定していたカラムが存在しなかったため、適切なカラムを指定。

# app/controllers/application_controller.rb
# 修正前
@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?

課題3「Postの投稿ができない」

原因・修正内容: 存在しないHTML属性を指定(誤記)したため、適切なHTML属性を指定。

<!-- app/views/posts/_form.html.erb -->
<!-- 修正前 -->
<%= form.text_field :titlee %>
<!-- 修正後 -->
<%= form.text_field :title %>

Copy link
Copy Markdown
Owner

@DaichiSaito DaichiSaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants