title: How to solve undefined method `to_key' for #<Book::ActiveRecord_Relation:0x007fb709a6a8c0>?
body: <p>I am facing problems with undefined method `to_key'</p>
  
  <p>this is my books_controller.rb</p>
  
  <pre><code> class BooksController  &lt; ApplicationController
     def index
      @books = Book.where(user_id: current_user.id)
      end
   end
  </code></pre>
  
  <p>and my index page as follow.</p>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;div&gt;
    &lt;%= form_for @books do |f| %&gt;
  ...
  ...
      &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>now when I am going to access index page that time I got an error as follow.</p>
  
  <pre><code>undefined method `to_key' for #&lt;Book::ActiveRecord_Relation:0x007fb709a6a8c0&gt;
  </code></pre>