NoMethodError... but its not a method!

Hi everyone,
I am putting together an application in which each part of it was
tested individually. Now that it is put together, I'm having problems...
The one giving me problems is my "ImportController" which parses a CSV
during post and puts it into my database. I have two separate CSV upload
actions (one is for a bill called "bes" and the other from the provider
"prov"). The one for BES works fine. Prov worked perfectly fine before,
but now it gives me this error:

undefined method `prov_charges_tot=' for #<Prov:0x4674734>

The thing is, thats not even supposed to be a method! The relevant part
of the view looks like this:

<% form_for :dump, :url => { :controller => 'import', :action => 'bes'
}, :html => { :multipart => true } do |f| -%>
<label for="dump_file">Select a BES CSV File :</label>
     <%= f.file_field :file -%>
     <%= submit_tag 'Submit' -%>
<% end -%>

<% form_for :dump, :url => { :controller => 'import', :action => 'prov'
}, :html => { :multipart => true } do |f| -%>
<label for="dump_file">Select a Provider CSV File :</label>
     <%= f.file_field :file -%>
     <%= submit_tag 'Submit' -%>
<% end -%>

Perhaps it is a naming problem? I am not sure. My controller looks like

def bes
@currenttime =
@parsed_file = FasterCSV::parse(params[:dump][:file])
@parsed_file.each do |row|
     # There are a bunch more of these lines, but this part works.
   @besnumber = params[:bes]

  GC.start if n%50==0
  Bes.delete_all(["created_at < ?", @currenttime])[:message] = 'CSV BES Import Successful'

def prov
     @currenttime =
     @parsed_file = FasterCSV::parse(params[:dump][:file])
     @parsed_file.each do |row|


  c.prov_charges_tot=row[43] # THIS IS WHERE THE ERROR OCCURS


        GC.start if n%50==0

     Prov.delete_all(["created_at < ?", @currenttime])[:message] = 'CSV Import Successful'


My models are just empty, so nothing to worry about there. I am really
having a frustrating time with this one... I think it would be a naming
thing, but I really don't know.

Any help is greatly appreciated! Thank you all very much!
- Jeff Miller

I got it, I forgot I added that column after I migrated the database...
thus, there was no prov_charges_tot column... stupid me...

Thanks anyway!
- Jeff


That's a lot of very repetitive code in your prov method. You could
use a hash and really clean that up (and possibly make it easier to

At the top of the method (or maybe as a constant on the Prov class?)
add something like this:
prov_map = {:prov_info_fac => 0, :prov_info_bac
=>3, :prov_info_cycle_end_date=>5, ... }

then your processing loop looks like:

@parsed_file.each do |row|
  prov_map.each{|attr, column| c.send "#{att}r=", row[column] }