title: Ajax upload POST data not inserting into database in Rails 3
body: <p>I'm having a heck of a time grabbing a param from my POST array and inserting it into a MySQL database. The file is submitted to a RAILS 3 controller that should pull the filename and use it as a value in an SQL statement. This is my controller:</p>
  
  <pre><code>def upload
      @item= Item.new(params[:qqfile])
      Rails.logger.info("PARAMS: #{params.inspect}")
      # if params array contains :qqfile
      unless params[:qqfile].empty?
        # model should:
        # copy file to uploads directory
        render_success
        if @item.save
  
        else
          render :text =&gt; 'database did not save'
        end
        # redirect to render success action
      else
        render :text =&gt; '{success:false}'
      end
    end
  </code></pre>
  
  <p>The log shows that the query is running but with a NULL value:</p>
  
  <pre><code>Started POST "/item/upload?qqfile=1eCH6.jpg" for 127.0.0.1 at Fri Jan 07 09:16:0
  9 -0700 2011
    Processing by ItemController#upload as HTML
    Parameters: {"qqfile"=&gt;"1eCH6.jpg"}
  PARAMS: {"qqfile"=&gt;"1eCH6.jpg", "controller"=&gt;"item", "action"=&gt;"upload"}
  Rendered text template (0.0ms)
    SQL (0.0ms)  INSERT INTO `items` (`name`, `qqfile`, `created_at`, `updated_at`
  ) VALUES (NULL, NULL, '2011-01-07 16:16:10', '2011-01-07 16:16:10')
  Completed 200 OK in 359ms (Views: 16.0ms | ActiveRecord: 0.0ms)
  </code></pre>
  
  <p>The key is there in the array. I'm confused why the controller isn't using its value for the value in the SQL query.</p>