I'm currently new to Rails and Ruby and I'm trying to learn from my 
mistakes, this time I'm trying to upload 2 files from a form for later 
processing, however, after I hit the "Submit" button. I keep getting this 
error:

TypeError in UploadFilesController#create

app/controllers/upload_files_controller.rb:28:in `new'
app/controllers/upload_files_controller.rb:28:in `create'

Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"2JJGtRXjWCZlPNhQdx6wOW4xvTseiRaXNylnUYvA5v4=",
 "upload_files"=>{"inventory"=>#<ActionDispatch::Http::UploadedFile:0x2fd8940 
@original_filename="1_Inventory.xlsx",
 
@content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
 @headers="Content-Disposition: form-data; name=\"upload_files[inventory]\"; 
filename=\"1_Inventory.xlsx\"\r\nContent-Type: 
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n",
 
@tempfile=#<Tempfile:C:/Users/V80042~1/AppData/Local/Temp/RackMultipart20130930-9236-qiqijn>>,
 "material_list"=>#<ActionDispatch::Http::UploadedFile:0x2fe3cf8 
@original_filename="2_Material_List.xlsx",
 
@content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
 @headers="Content-Disposition: form-data; 
name=\"upload_files[material_list]\"; 
filename=\"2_Material_List.xlsx\"\r\nContent-Type: 
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n",
 
@tempfile=#<Tempfile:C:/Users/V80042~1/AppData/Local/Temp/RackMultipart20130930-9236-g22588>>},
 "commit"=>"Upload"}

My upload_files_controller:

 class UploadFilesController < ApplicationController
     def new
        @uploadFiles = UploadFiles.newend

  def create
    @uploadFiles = UploadFiles.new(params[:upload_files])end

Models:

Upload_Files:

class UploadFiles < ActiveRecord::Base
  attr_accessible :inventory, :material_list
  has_one :inventory
  has_one :material_list
  has_attached_file :inventory, :material_list

  def new
    {
      "name" => read_attribute(:upload_file_name),
      "size" => read_attribute(:upload_file_size),
      "url" => upload_file.url(:original),
      "delete_url" => upload_file_path(self),
      "delete_type" => "DELETE" 
      }
  endend

Inventory:

class Inventory < ActiveRecord::Base
  belongs_to :upload_filesend

Material List:

class MaterialList < ActiveRecord::Base
  belongs_to :upload_filesend

_form:

<%= form_for :upload_files do |f| %><h3>Upload Inventory</h3><%= f.file_field 
:inventory %><h3>Upload Product List</h3><%= f.file_field :material_list %><div 
class="actions">
    <%= f.submit "Upload" %></div><% end %>

Could you please tell me what am I doing wrong and how to fix it? Thank you 
in advance.


Note: In case you haven't noticed, I'm using paperclip and rails 3.x.x

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1197451b-7c77-48fe-96ea-45783058f468%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to