title: Couldn't find Post with 'id'=#
body: <p>I am new to ruby and RoR. I am using the ruby gem <a href="https://rubygems.org/gems/acts_as_votable" rel="nofollow noreferrer">acts_as_votable</a> to let users like and unlike posts. I added a &quot;like&quot; button to <em>all posts</em> on my <em>posts/index</em> page.</p>
  <p>The button displays correctly and I am trying to make a button click like/unlike the post it is displayed on. When I click the button, to like a post, I get this error:</p>
  <pre><code>Couldn't find Post with 'id'=#&lt;Post::ActiveRecord_Relation:0x00000002ba3b30&gt;
    def find_post
      @post = Post.find(params[:id])
    end
  </code></pre>
  <p>BTW: If you need anymore information, I will provide whatever I can.</p>
  <h1>EDIT</h1>
  <p>Index page</p>
  <pre><code>- @post.each do |post|
      .box.panel.panel-default
        = link_to (image_tag post.image.url), post
        .post-actions
          = render &quot;posts/actions&quot;
        .panel-body
          %h2= link_to post.caption, post
  </code></pre>
  <p>Posts controller</p>
  <pre><code>      class PostsController &lt; ApplicationController
    before_action :find_post, only: [:show, :edit, :update, :destroy, :upvote]
    before_action :authenticate_user!, except: [:index, :show]
  
    def index
      @post = Post.all.order(&quot;created_at DESC&quot;)
    end
  
    def new
      @post = current_user.posts.build
    end
  
    def create
      @post = current_user.posts.build(post_params)
  
      if @post.save
        redirect_to @post, notice: &quot;Success! Your new post has been created.&quot;
      else
        render 'new'
      end
    end
  
    def show
  
    end
  
    def edit
  
    end
  
    def update
      if @post.update(post_params)
        redirect_to @post, notice: &quot;Success! You updated your post.&quot;
      else
        render 'edit'
      end
    end
  
    def destroy
      @post.destroy
  
      redirect_to root_path
    end
  
    def upvote
      @post.upvote_by current_user
      redirect_to :back
    end
  
    private
  
    def post_params
      params.require(:post).permit(:caption, :image)
    end
  
    def find_post
      @post = Post.find(params[:id])
    end
  end
  </code></pre>
  <p>Routes</p>
  <pre><code>Rails.application.routes.draw do
    devise_for :users
    resources :posts do
      member do
        put &quot;admire&quot;, to: &quot;posts#upvote&quot;
      end
    end
  
    root &quot;posts#index&quot;
  end
  </code></pre>
  <p>In terminal, I entered: rake routes. Here is the response:</p>
  <pre><code>                 Prefix Verb   URI Pattern                    Controller#Action
          new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
              user_session POST   /users/sign_in(.:format)       devise/sessions#create
      destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
             user_password POST   /users/password(.:format)      devise/passwords#create
         new_user_password GET    /users/password/new(.:format)  devise/passwords#new
        edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                           PATCH  /users/password(.:format)      devise/passwords#update
                           PUT    /users/password(.:format)      devise/passwords#update
  cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
         user_registration POST   /users(.:format)               devise/registrations#create
     new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
    edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                           PATCH  /users(.:format)               devise/registrations#update
                           PUT    /users(.:format)               devise/registrations#update
                           DELETE /users(.:format)               devise/registrations#destroy
               admire_post PUT    /posts/:id/admire(.:format)    posts#upvote
                     posts GET    /posts(.:format)               posts#index
                           POST   /posts(.:format)               posts#create
                  new_post GET    /posts/new(.:format)           posts#new
                 edit_post GET    /posts/:id/edit(.:format)      posts#edit
                      post GET    /posts/:id(.:format)           posts#show
                           PATCH  /posts/:id(.:format)           posts#update
                           PUT    /posts/:id(.:format)           posts#update
                           DELETE /posts/:id(.:format)           posts#destroy
                      root GET    /                              posts#index
  </code></pre>