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
this:
def bes
@currenttime = Time.now
@parsed_file = FasterCSV::parse(params[:dump][:file])
@parsed_file.shift
n=0
@parsed_file.each do |row|
c=Bes.new
c.bes_id=row[0]
# There are a bunch more of these lines, but this part works.
c.bes_handheldconfigid=row[21]
@besnumber = Bes.new params[:bes]
if c.save
n=n+1
GC.start if n%50==0
end
Bes.delete_all(["created_at < ?", @currenttime])
flash.now[:message] = ''CSV BES Import Successful''
end
end
def prov
@currenttime = Time.now
@parsed_file = FasterCSV::parse(params[:dump][:file])
@parsed_file.shift
n=0
@parsed_file.each do |row|
c=Prov.new
c.prov_info_fac=row[0]
c.prov_info_bac=row[3]
c.prov_info_cycle_end_date=row[5]
c.prov_service_name=row[1]
c.prov_service_number=row[2]
c.prov_service_provider=row[4]
c.prov_charges_tot=row[43] # THIS IS WHERE THE ERROR OCCURS
c.prov_charges_tot_access=row[6]
c.prov_charges_tot_airtime=row[7]
c.prov_charges_tot_kb=row[8]
c.prov_charges_tot_messaging=row[9]
c.prov_charges_tot_features=row[12]
c.prov_charges_tot_equipment=row[25]
c.prov_charges_tot_longdistance=row[26]
c.prov_charges_tot_roaming=row[30]
c.prov_charges_tot_misc=row[38]
c.prov_charges_tot_other=row[41]
c.prov_charges_tot_taxesfees=row[42]
c.prov_charges_messaging_sms=row[10]
c.prov_charges_messaging_mms=row[12]
c.prov_charges_feat_basicvoice=row[14]
c.prov_charges_feat_voicemail=row[15]
c.prov_charges_feat_wos=row[16]
c.prov_charges_feat_aod=row[17]
c.prov_charges_feat_intnl=row[18]
c.prov_charges_feat_mou=row[19]
c.prov_charges_feat_data=row[20]
c.prov_charges_feat_vidshare=row[21]
c.prov_charges_feat_wifi=row[22]
c.prov_charges_feat_messaging=row[23]
c.prov_charges_feat_otherfees=row[24]
c.prov_charges_feat_otherfeat=row[25]
c.prov_charges_ld_local=row[28]
c.prov_charges_ld_intnl=row[29]
c.prov_charges_ld_directory=row[30]
c.prov_charges_roam_airtime=row[32]
c.prov_charges_roam_kb=row[33]
c.prov_charges_roam_surcharges=row[34]
c.prov_charges_roam_ld=row[35]
c.prov_charges_roam_intnl=row[36]
c.prov_charges_roam_intnl_ld=row[37]
c.prov_charges_roam_taxes=row[38]
c.prov_charges_misc_voice=row[40]
c.prov_charges_misc_data=row[41]
if c.save
n=n+1
GC.start if n%50==0
end
Prov.delete_all(["created_at < ?", @currenttime])
flash.now[:message] = ''CSV Import Successful''
end
end
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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---