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

  • SEARCH
  • Home
  • 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 4007792
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:40:29+00:00 2026-05-20T08:40:29+00:00

Despite the other excellent answers here to similar posts, I cannot see the error

  • 0

Despite the other excellent answers here to similar posts, I cannot see the error in my code that is producing this error: “undefined method `parse_file’ for…”
I’m using RoR (Rails 2.1) and am simply trying to upload and parse a csv file using FasterCSV plugin. I am also saving a record of the file’s filename in the Upload table.

Many thanks for any help (this is driving me nuts…):

my model:

   require 'fastercsv'

  def new

    @upload = Upload.new

  end

  def self.parse_file(file)    

    FasterCSV.foreach(file.path,:headers=>"first_row", :col_sep=>"\t") do |row|
      row.each{|row| puts "row: #{row.inspect}"}
    end

  end

my controller:

 def create

    @upload = Upload.new    
    thefile = params[:upload][:upload_file]
    @upload.filename = base_part_of(thefile.original_filename)
    @upload.parse_file(thefile)

    respond_to do |format|
      if @upload.save
        flash[:notice] = 'Upload was successful.'
        format.html { redirect_to(@upload) }
        format.xml  { render :xml => @upload, :status => :created, :location => @upload }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @upload.errors, :status => :unprocessable_entity }
      end
    end

  end


  def base_part_of(file_name)
      File.basename(file_name)
  end

my view:

<% form_for(:upload,
             :url => {:action=> :create},
             :html => { :multipart => true} ) do |form| %>

  Upload your file: <%= form.file_field("upload_file",:size=>50,:class => "csv-input") %><br/>

  <%= submit_tag("Upload") %>

<% end %>

the (partial) stack trace of the error:

vendor/rails/activerecord/lib/active_record/attribute_methods.rb:256:in `method_missing'
vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:580:in `call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:573:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
...
  • 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-20T08:40:30+00:00Added an answer on May 20, 2026 at 8:40 am

    You are calling a class method (Upload.parse_file) on an instance (@upload). Either change your definition:

    class Upload
      def parse_file(file)
        FasterCSV.foreach(file.path,:headers=>"first_row", :col_sep=>"\t") do |row|
          row.each{|row| puts "row: #{row.inspect}"}
        end
      end
    end
    

    or change your call:

    Upload.parse_file(thefile)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Despite this being one of the best error messages I've ever seen (second only
Despite reading lots of other posts regarding GIT and moved files I still struggle
Despite an earlier question ( asked here ), our project is constrained to using
I know very little about JavaScript but despite this I'm trying to cobble something
Despite primarily being a windows user, I am a huge fan of rsync. Now,
Despite having very little Linux experience, I'm too enticed by VPS (and too sick
Despite enabling WSE 3.0 on client projects in Visual Studio 2005, web references I
Why are SQL distributions so non-standard despite an ANSI standard existing for SQL? Are
I have to work on several VB6 legacy projects and despite some good VB6
Unfortunately, despite having tried to learn regex at least one time a year for

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.