title: paperclip validations causing Error in Rails 3
body: <p>I've recently installed the paperclip gem to my Rails 3 app. I am trying to allow users to upload an avatar to their profile. I followed the install instructions and here is what my models/views look like:</p>
  
  <p>My 'user.rb' model has the following code: </p>
  
  <pre><code>has_attached_file :avatar, 
                    :styles =&gt; { :small =&gt; "70x70&gt;"},
                    :url  =&gt; "/users/:attachment/:id/:style/:basename.:extension",
                    :path =&gt; ":rails_root/public/users/:attachment/:id/:style/:basename.:extension"
  
  validates_attachment_size :avatar, :less_than =&gt; 1.megabytes
  validates_attachment_content_type :avatar, :content_type =&gt; ['image/jpeg', 'image/png']
  </code></pre>
  
  <p>I have added the following to the edit form html (I'm using HAML btw):</p>
  
  <pre><code>= form_for (@user || User.new), :html =&gt; { :multipart =&gt; true } do |f|
  ...
  .profile_picture.text_field
    = image_tag current_profile.avatar.url(:small)
    %br
    = f.file_field :avatar
  </code></pre>
  
  <p>When I upload a picture (jpeg or png) that is under 1mb everything works smoothly; the image is uploaded, and there are no errors. If I try to upload any other type of file (MP3, txt, whatever) or the file/image is greater than 1mb rails gives me the following error:</p>
  
  <pre><code>TypeError in UsersController#update
  
  can't dump File
  
  Request
  
  Parameters:
  
  {"utf8"=&gt;"✓",
   "_method"=&gt;"put",
   "authenticity_token"=&gt;"LaiYjEEfgsE8JzzLsfkzk6TK8D4uxzIo5ASlu6ax2rY=",
   "user"=&gt;{"avatar"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x000001053f0bf0 @original_filename="GT1_22HS_1_std.jpg",
   @content_type="image/jpeg",
   @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"GT1_22HS_1_std.jpg\"\r\nContent-Type: image/jpeg\r\n",
   @tempfile=#&lt;File:/var/folders/Ud/Udv4OlryEzWrHedR8pIe1E+++TI/-Tmp-/RackMultipart20110817-17075-1ikqcc0&gt;&gt;,
   "first_name"=&gt;"First",
   "last_name"=&gt;"Last",
   "country"=&gt;"United States",
   "state"=&gt;"California",
   "city"=&gt;"City",
   "date_of_birth(1i)"=&gt;"2011",
   "date_of_birth(2i)"=&gt;"7",
   "date_of_birth(3i)"=&gt;"12",
   "account_attributes"=&gt;{"email"=&gt;"email@email.com",
   "id"=&gt;"6",
   "password"=&gt;"[FILTERED]",
   "password_confirmation"=&gt;"[FILTERED]"},
   "commit"=&gt;"Save &amp; Continue",
   "id"=&gt;"2"}
  </code></pre>
  
  <p>I apologize if all of that was not required, but the error is a little non-descriptive, so I figured it's better to post in just in case.</p>
  
  <p>I would like to know what I'm doing wrong with my validations that errors are not being generated, and the application is breaking. Any help on this matter would be greatly appreciated. I sincerely thank everyone who took the time to read this, and I kindly appreciate any help! Thanks!</p>
  
  <p>UPDATE:</p>
  
  <pre><code>update method form user_controller.rb:
  
    def update
      session[:user_params] ||= {}
      session[:user_params].deep_merge!(params[:user]) if params[:user].present?
  
      @user.attributes = session[:user_params]
  
      respond_to do |format|
        if @user.save
          session[:user_params] = nil
          sign_in(@user.account, :bypass =&gt; true)
          format.html { redirect_to(root_url, :notice =&gt; 'User was successfully updated.') }
          format.xml  { render :xml =&gt; @user, :status =&gt; :created, :location =&gt; @user }
        else
          format.html { render :action =&gt; "edit", :layout =&gt; "userhome" }
          format.xml  { render :xml =&gt; @user.errors, :status =&gt; :unprocessable_entity }
        end
      end
    end
  </code></pre>