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 429565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:47:17+00:00 2026-05-12T19:47:17+00:00

I have a page where a user can import data to the site. either

  • 0

I have a page where a user can import data to the site. either in the form of copy and pasting into a text area from excel, or by uploading a .csv file.

The controller checks if a csv has been uploaded – if so it processes this, else it will process the pasted content. (working on the assumption the user will only choose one option for now).

The copy and paste part works perfectly, however, the problem arises when I try to process the uploaded csv file:

I get the error:

can’t convert
ActionController::UploadedTempfile
into String

#events_controller
  def invite_save
    @event = Event.find(params[:id])

    if params[:guest_list_csv]
      lines = parse_csv_file(params[:guest_list_csv])
    else
      #csv file uploaded
      lines = params[:guest_list_paste]
    end

    if lines.size > 0
      lines.each do |line|
          new_user(line.split)
      end 
      flash[:notice] = "List processing was successful."
    else
      flash[:error] = "List data processing failed."
    end

  end
private

  def parse_csv_file(path_to_csv)
    lines = []

    require 'fastercsv' 

    FasterCSV.foreach(path_to_csv) do |row|
      lines << row
    end
    lines
  end

  def new_user(line)
     #code to create new user would go here
  end

I’m essentially trying to upload and process the csv in one smooth action, rather than have to get the user to press a “process” button.

  • 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-05-12T19:47:17+00:00Added an answer on May 12, 2026 at 7:47 pm

    On the line #6 above

    if params[:guest_list_csv]
      lines = parse_csv_file(params[:guest_list_csv])
    else
      #csv file uploaded
      lines = params[:guest_list_paste]
    end
    

    The problem is params[:guest_list_csv] is not the actual string, neither is the path, since it’s a file object. What you need is explicitly call #path on it.

    # line 6
      lines = parse_csv_file(params[:guest_list_csv].path)
    

    Please try it and see if it fixes your problem.

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

Sidebar

Related Questions

I have a page upon which a user can choose up to many different
We have a page of search results which the user can hit in several
I have a page that contains a user control that is just a personalized
I have an aspx page,where the user will enter a valid image url(ex :
I have a web page where the user will enter their address. They will
I have a page with a Print link that takes the user to a
I have a page that is trying to login a user. at the top
I have a Page with a UserControl on it. If the user presses Esc
Let's say I have a page called display.php and the user is viewing display.php?page=3
I have a login page where I authenticate the user. When the authentication pass,

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.