ツイッターのような簡易アプリを作成しています。

form_forを使って、ツイートに対するコメント投稿機能を実装しようとしています。
その際、以下のようなエラーが発生しました。
NoMethodError in CommentsController#create
undefined method `comments' for nil:NilClass

解決するための方法をお教え願います。

エラーの発生箇所
app/controllers/comments_controller.rbの5行目
https://gyazo.com/debe434b841603ca71133c86bebcd9c1

エラーの内容
Commentsの対象である@commentの中身がnilであることが原因でエラーが発生している。

デバッグ(binding.pry)の検証

ツイーツコントローラ
https://gyazo.com/5edd365c30701a7453ac5df51e23cb9a

フォーム画面
https://gyazo.com/23060c848471cf954c9ff70e54dcfe7a

コメントコントーラー
https://gyazo.com/5473ed1805bdeb0842bd912adab8974e

デバッグ結果
コメントをリクエストしたところまでは、データの取得ができていた。そして、CommentsControlle
で取得できていたデータが取得できなくなった。したがって、リクエストの段階でのエラーであることが推測できた。

仮説
1.ルーティングの設定が間違っていること。
2.form_forの記述が間違っていること。

検証
1.については、rake routesコマンドでパスを調べたところ、パスの指定はあっていた。
https://gyazo.com/7c602e391947d9bd7fa23187cbcbffd5

2.については、form_forの書き方を以下のように、form_forの直後に引数のカッコを記述してみたが、変化はなかった。


<%= form_for( [@tweet, @comment] ) do |f| %>

コードの全体

config/routes.rb


Rails.application.routes.draw do
  devise_for :users
  root 'tweets#index'
  resources :tweets do
    resources :comments, only: [:create]
  end
  resources :users, only: [:show]
end

app/controllers/tweets_controller.rb


def show
    @tweet = Tweet.find(params[:id])
    @comments = @tweet.comments.includes(:user)
    @comment = @tweet.comments.new
 end

app/views/tweets/show.html.erb

<%= form_for ( [@tweet, @comment] ) do |f| %>
    <%= f.text_area :text, placeholder: "text" %>
    <%= f.submit "送信"%> 
 <% end %>

app/controllers/comments_controller.rb


class CommentsController < ApplicationController  

  def create
    @comment = @comment.comments.create(text: comment_params[:text], tweet_id: comment_params[:tweet_id], user_id: current_user.id)
    redirect_to "/tweets/#{@comment.tweet.id}"
  end

  private
  def comment_params
    params.require(:comment).permit(:text, :tweet_id)
  end
end