Home>

It's been a week since I started studying.
I want to save using the create action, but I get an error.
I'm sorry for lack of study, but I would like to know.

NoMethodError in BooksController # create
undefined method `book'for #<Book: 0x00007fa5e8083460>
routes
root to:'books # top'
  get'top' =>'books # top'
  get'book/new'
  get'index' =>'books # index'
  post'books' =>'books # create'
  get'books /: id'=>'books # show', as:'book'
  get'book /: id', to:'books # show'
  get'books /: id/edit'=>'books # edit', as:'edit_book'
  patch'books /: id'=>'books # update', as:'update_book'
  delete'books /: id'=>'books # destroy', as:'destroy_book'
end
book controller
def self.book
  end
  def index
    @books = Book.all
  end
  def new
    @book = Book.new
  end
  def create
    book = Book.new (book_params)
    book.save
    redirect_to'/ index'
  end
  def show
    @book = Book.find (params [: id])
  end
  def edit
    @book = Book.find (params [: id])
  end
  def update
    book = Book.find (params [: id])
    book.update (book_params)
    redirect_to book_path (book.id)
  end
  def destroy
    book = Book.find (params [: id])
    book.destroy
    redirect_to'/ index'
  end

  private
  def book_params
    params.require (: book) .permit (: title,: body)
  end
end
index file
<% @ books.each do | book |%>
   title 
<span><% = book.title%></span>
   body 
<span><% = book.body%></span>
<p>
  <% = link_to "show", book_path (book.id)%>
  <% = link_to "edit", edit_book_path (book.id)%>
  <% = link_to "destroy", destroy_book_path (book.id), method:: delete, "data-confirm" =>"Are you sure I want to delete?"%>
</p>
<% end%>

<% = form_with model: Book.new, url:'/ books', local: true do | f |%>
   title 
<% = f.text_field: title%>
   Body 
<% = f.text_area: body%>
<% = f.submit'new post'%>
<% end%>