Home>

I am making a posting function with rails.
The following error occurs when executing the create method.

Error message
No route matches {: action =>"show",: controller =>"books",: id =>nil}, missing required keys: [: id]
### Applicable source code
Description in # books.controller #
 Def new
    @book = Book.new
  end
  def create
    @book = Book.new (book_params)
    @ book.save
    redirect_to book_path (@ book.id)
  end
~~~~ Abbreviation ~~~~
  private
  def book_params
    params.require (: book) .permit (: Title,: Opinion)
  end
end

Description in # books/view/_new.book.html.erb #
 New book 
<% = form_for: book, url: books_path do | f |%>
<P>Title</P>
<p>
<% = f.text_field: Title%>
</p>
<P>Opinion</P>
<p>
<% = f.text_area: Opinion%>
</p>
<p>
<% = f.submit%>
</p>
<% end%>

Enter the language name here
Source code
`` ```

What I tried

I tried everything I looked up.
I understand that id is nil, but
I don't understand why the id is not given.

Supplementary information (FW/tool version, etc.)

ruby 2.5.7