title: Why doesn't paperclip save uploaded image?
body: <p>I have a model called employers and I'm using paperclip to upload images. It was working before but for some reason, it has stopped working. I am asking the user to fill a form out with name, company, and a profile pic. In my controller, I have set it so the form doesn't get submitted if something is wrong. The user gets redirected to the homepage if the form gets submitted and the form is rendered again if something is wrong. Right now, the form gets submitted. In my development logs, the name of the picture is also there. My development long looks like this (I am updating the form here, same concept as new form):</p>
  
  <pre><code>Started PATCH "/employers/werwer" for ::1 at 2017-06-28 21:37:15 -0400
  Processing by EmployersController#update as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"JeftOiYu26+Vxo/f6NSigrUzHaTsukGvIoGxUVJkH4OGK+HcAs7fH5DWWDHnZiFTYs0/YqN4ZhAYxgwqmSfo7w==", "employer"=&gt;{"name"=&gt;"werwer", "company"=&gt;"werwe", "position"=&gt;"werwer", "number"=&gt;"345345", "email"=&gt;"dinukap999@gmail.com"}, "picture"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x0000000b570bb0 @tempfile=#&lt;Tempfile:C:/Users/dinuka/AppData/Local/Temp/RackMultipart20170628-7872-a8xds6.png&gt;, @original_filename="icons8-Manager-48.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"picture\"; filename=\"icons8-Manager-48.png\"\r\nContent-Type: image/png\r\n"&gt;, "commit"=&gt;"Update Employer", "id"=&gt;"werwer"}
    [1m[35mEmployer Load (1.0ms)[0m  SELECT  "employers".* FROM "employers" WHERE "employers"."slug" = ?  ORDER BY "employers"."id" ASC LIMIT 1  [["slug", "werwer"]]
    [1m[36m (1.0ms)[0m  [1mbegin transaction[0m
    [1m[35m (1.0ms)[0m  commit transaction
  Redirected to http://localhost:3000/employers/werwer
  Completed 302 Found in 35ms (ActiveRecord: 3.0ms)
  </code></pre>
  
  <p>As you can see, the pic with name "a8xds6.png" is shown on the the third line. But I'm not sure why it's submitted as a temp file. </p>
  
  <p>When I open up the rails console and see the data of that particular employer, everything else except the image is updated. The image says "nil".</p>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;%= simple_form_for @employer do |f| %&gt;
      &lt;%= f.input :name, required: true, label: 'Full name'  %&gt;
      &lt;%= f.input :company, required: true, label: 'Name of company' %&gt;
      &lt;%= f.file_field :emp_img, required: true, name: 'picture' %&gt;
      &lt;%= f.button :submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class EmployersController &lt; ApplicationController
      before_action :find_employer, only: [:show, :edit, :update, :destroy]
  
      def index 
      end
  
      def show
      end
  
      def new
          @employer = current_user.build_employer
      end
  
      def create
          @employer = current_user.build_employer(employer_params)
          if @employer.save
            redirect_to userinfos_path
          else
            render 'new'
          end
      end
  
      def edit
      end
  
      def update
          if @employer.update(employer_params)
              redirect_to employer_path(@employer)
          else
              render 'edit'
          end
      end
  
      def destroy
          @employer.destroy
          redirect_to root_path
      end
  
      private
          def employer_params          
              params.require(:employer).permit(:name, :company, :emp_img)
          end
  
          def find_employer
              @employer = Employer.friendly.find(params[:id])
          end 
  end
  </code></pre>
  
  <p>Employer model:</p>
  
  <pre><code>class Employer &lt; ActiveRecord::Base
      belongs_to :user
  
      has_attached_file :emp_img, :styles =&gt; { :profile_pic =&gt; "200x200&gt;" }, :default_url =&gt; "/images/:style/missing10.png"
      validates_attachment_content_type :emp_img, :content_type =&gt; /\Aimage\/.*\Z/
  end
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;%= image_tag @employer.emp_img.url(:profile_pic) %&gt;
  </code></pre>
  
  <p>Please let me know what I need to change or if you need any more information. I know the development logs show more parameters than that are in the forms, I removed some params to simplify the question.</p>