title: Rails 3 - Paperclip: uninitialized constant ActionDispatch::Request::UploadedFile
body: <p>I have a confusing error:</p>
  
  <p>I run Rails 3.0.0 on Ruby 1.9.2 with Paperclip 2.3.5.</p>
  
  <p>When I upload a file I get a 500 error. </p>
  
  <pre><code>NameError (uninitialized constant ActionDispatch::Request::UploadedFile):
    config/initializers/fix_params.rb:13:in `normalize_parameters'
    config/initializers/fix_params.rb:19:in `block in normalize_parameters'
    config/initializers/fix_params.rb:19:in `each'
    config/initializers/fix_params.rb:19:in `normalize_parameters'
    config/initializers/fix_params.rb:19:in `block in normalize_parameters'
    config/initializers/fix_params.rb:19:in `each'
    config/initializers/fix_params.rb:19:in `normalize_parameters'
  
  Rendered /Users/vjmayr/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.2ms)
  </code></pre>
  
  <hr>
  
  <p>I have seen similar things happen with Rails 3.0.2 and .3 but I have no idea why it happens here. Con anyone help me with finding the problem?</p>
  
  <p>Thanks! Valentin</p>
  
  <p>ADDED config/initializers/fix_params.rb:</p>
  
  <pre><code>module ActionController
    class Request
      private
  
        # Convert nested Hashs to HashWithIndifferentAccess and replace
        # file upload hashs with UploadedFile objects
        def normalize_parameters(value)
          case value
          when Hash
            if value.has_key?(:tempfile)
              upload = value[:tempfile]
              upload.extend(UploadedFile)
              upload.original_path = value[:filename]
              upload.content_type = value[:type]
              upload
            else
              h = {}
              value.each { |k, v| h[k] = normalize_parameters(v) }
              h.with_indifferent_access
            end
          when Array
            value.map { |e| normalize_parameters(e) }
         else
            value.force_encoding(Encoding::UTF_8) if value.respond_to?(:force_encoding)
            value
           end
        end
    end
  end
  </code></pre>