Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:52:19+00:00 2026-06-10T14:52:19+00:00

I have a simple file upload form where a user should be able to

  • 0

I have a simple file upload form where a user should be able to select a csv file from their machine and then save it to a file folder. I am trying to user Carrierwave and my app is built in Ruby on Rails.

When I try to save the file, I get the error “No route matches [POST] “/customers/new”.

Here are the various components.

/new.html.erb

<%= form_for :dataload, :html => {:multipart => true}  do |f| %>

 <p>
   <%= f.file_field :file %>
 </p>
 <p><%= f.submit %></p>
<% end %>

/models/dataload.rb

class Dataload < ActiveRecord::Base
    attr_accessible :file_name, :request_user, :source
    mount_uploader :file, CustomerWarrantyUploader
end

*/uploaders/customer_warranty_uploader.rb*

class CustomerWarrantyUploader < CarrierWave::Uploader::Base
  storage :file
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
  def extension_white_list
   %w(csv)
  end

*customers_controller.rb (new method; I haven’t done anything to this)*

  def new
    @customer = Customer.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @customer }
    end
  end

Here are the current routes for customers

  resources :customers

I am not sure what the issue is, having tried various similar approaches. Any advice is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:52:21+00:00Added an answer on June 10, 2026 at 2:52 pm

    The reason is because that route really doesn’t exist. Resources creates the following routes ( http://guides.rubyonrails.org/routing.html ):

    GET     /customers          index   display a list of all photos
    GET     /customers/new      new     return an HTML form for creating a new photo
    POST    /customers          create  create a new photo
    GET     /customers/:id      show    display a specific photo
    GET     /customers/:id/edit edit    return an HTML form for editing a photo
    PUT     /customers/:id      update  update a specific photo
    DELETE  /customers/:id      destroy delete a specific photo 
    

    As you can see, the only POST path is /customers. A simple adjustment to your form should do the trick. Something like the following should work:

    <%= form_for :dataload, { :url => customers_path , :html => {:multipart => true} }  do |f| %>
    

    Edit: Adding additional information as a result of user comments.

    You will also need to add some logic to your controller, to deal with the uploaded file. Basically, in the Railscast, he states “Part of the site is already built: there is a page that lists the galleries, with a link to each gallery and a page that shows a gallery’s pictures.”. This apparently includes a new and edit page, as well. The code from his controller ( from the project source code – http://media.railscasts.com/assets/episodes/sources/253-carrierwave-file-uploads.zip ) is:

    @gallery = Gallery.new(params[:gallery])
    

    So, when he added his file, he did it as an attribute on the model, so all he had to add was the attr_accessible :image bit to the model to make the controller automagically start handling the image (as it comes through in the same params). As yours is coming through in different params (:dataload), and not as an attribute on the model, you will likely need to add more code than he has, using your current technique. Maybe something along the lines of:

    @dataload = Dataload.create(params[:dataload])
    

    or even:

    @dataload = Dataload.process_uploaded_file(params[:dataload])
    

    Then, you would add a process_uploaded_file method to your Dataload to kick off your relevant Customer creation logic…

    Another thing not really handled, yet, is what will happen when there are errors in the data. For example, what will you do (and how will you present the errors) if 2 out of 10 entries in the uploaded file create invalid records?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple file upload form. How do I make it submit automatically
I have a very simple page with which a user uploads a file. Using
I'm trying to create a simple file upload form for my website. I'm using
I have a simple swf file upload script that uploads a file as soon
Let's say that I have a file (file1.php) with a simple form with the
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I have a picture upload inside a form... The file is a php file
I try to create simple file upload service in C++. I get all user
I'd like to have an <input type=file> form element that fires the upload process
I have a form with series of 3 file upload fields, each of which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.