title: undefined method `image' in my view
body: <p>I am using Paperclip, and my only problem is that in my image tag, I have an undefined method "image".</p>
  
  <pre><code>&lt;%= image_tag @posts.image.url(:medium) %&gt;
  </code></pre>
  
  <p>is where my error is occurring. When I loaded a new migration, I accidentally did "rails g paperclip user image" instead of "rails g paperclip posts image" so I went into my code and changed "user" to "posts." I asked something similar and someone mentioned that it was with my schema.rb file(?).</p>
  
  <p>Just to be safe, this is my post controller:</p>
  
  <pre><code> class PostsController &lt; ApplicationController
      def index
          @posts = Post.all.order('created_at DESC')
      end
  
      def new
          @post = Post.new
  
          if @post.save
              redirect_to @post
          else
              render 'new'
          end
      end
  
      def create
          @post = Post.new(post_params)
          @post.save
  
          redirect_to @post
      end
  
      def show
          @post = Post.find(params[:id])
      end
  
      def edit
          @post = Post.find(params[:id])
      end
  
      def update
          @post = Post.find(params[:id])
  
          if @post.update(params[:post].permit(:title, :body))
              redirect_to @post
          else
              render 'edit'
          end
      end
  
      def destroy
          @post = Post.find(params[:id])
          @post.destroy
  
          redirect_to root_path
      end
  
  
      private
      def post_params
          params.require(:post).permit(:title, :body, :image)
      end
  end
  </code></pre>
  
  <p>but here is my migration file:</p>
  
  <pre><code>class AddAttachmentImageToUsers &lt; ActiveRecord::Migration
    def self.up
      change_table :posts do |t|
        t.attachment :image
      end
    end
  
    def self.down
      remove_attachment :posts, :image
    end
  end
  </code></pre>
  
  <p>and my user.rb file:</p>
  
  <pre><code>has_attached_file :image, :styles =&gt; { large: '600x600&gt;', medium: '300x300&gt;', thumb: '150x150#' }
    validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
  </code></pre>