1. contactx = Array.new 2. if params[:dump][:dump] 3. FasterCSV.parse(params[:dump][:dump].read.chop, {:headers => true, :skip_blanks => true}) do |row| 4. contactx << Contact.new( 5. :FirstName => row["First Name"], 6. :LastName => row["Last Name"], 7. :email => row["Email Address"] 8. ) 9. end 10. Contact.import contactx This code works up to line 4. I get the error: "Array can''t be coerced into Fixnum" If I change "contactx << Contact.new(..." to "Contact.create(..." so that it uses active record to create the records, it works. So the problem is with either line 4 or 10. I''m stuck right now. Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I don''t have any ideas based on what you''ve provided so far. Can you show the Contact class? Can you show the full stack trace? Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The Contact class is empty: class Contact < ActiveRecord::Base end BTW, I already have require ''FasterCSV'' & require ''ar-extensions'' in the environment.rb file. On May 21, 9:38 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t have any ideas based on what you''ve provided so far. Can you > show the Contact class? Can you show the full stack trace? > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here is the Full Stack Trace: C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/lib/ar- extensions/import.rb:272:in `+'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/lib/ar- extensions/import.rb:272:in `import_without_validations_or_callbacks'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/lib/ar- extensions/import.rb:262:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/lib/ar- extensions/import.rb:262:in `import_without_validations_or_callbacks'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/lib/ar- extensions/import.rb:243:in `import_with_validations'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/lib/ar- extensions/import.rb:202:in `import'' app/controllers/test_controller.rb:14:in `index'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in `send'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in `perform_action_without_filters'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:697:in `call_filters'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:689:in `perform_action_without_benchmark'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/rescue.rb:199:in `perform_action_without_caching'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:678:in `perform_action'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/query_cache.rb:8:in `cache'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:677:in `perform_action'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in `send'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in `process_without_filters'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:685:in `process_without_session_management_support'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/session_management.rb:123:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:388:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:171:in `handle_request'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:115:in `dispatch'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:126:in `dispatch_cgi'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:9:in `dispatch'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/rails.rb:76:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/rails.rb:74:in `synchronize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/rails.rb:74:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:159:in `process_client'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:158:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:158:in `process_client'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:285:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:285:in `initialize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:285:in `new'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:285:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:268:in `initialize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:268:in `new'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel.rb:268:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/configurator.rb:282:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/configurator.rb:281:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/configurator.rb:281:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ bin/mongrel_rails:128:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ lib/mongrel/command.rb:212:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86-mswin32/ bin/mongrel_rails:281 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:489:in `load'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:489:in `load'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:342:in `new_constants_in'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:489:in `load'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/ servers/mongrel.rb:64 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in `gem_original_require'' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in `require'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in `require'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:342:in `new_constants_in'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in `require'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/ server.rb:39 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in `gem_original_require'' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 27:in `require'' script/server:3 -e:2:in `load'' -e:2 On May 21, 9:38 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t have any ideas based on what you''ve provided so far. Can you > show the Contact class? Can you show the full stack trace? > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The reason it is empty is because I''m just doing a test on this Ar- Extensions + FasterCSV combination. On May 21, 9:41 am, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> The Contact class is empty: > > class Contact < ActiveRecord::Base > end > > BTW, I already have require ''FasterCSV'' & require ''ar-extensions'' in > the environment.rb file. > > On May 21, 9:38 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > I don''t have any ideas based on what you''ve provided so far. Can you > > show the Contact class? Can you show the full stack trace? > > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Below is what the development.log spits out. Everything looks normal until WARNING: Can''t mass-assign these protected attributes: id. --------------------------------- Processing TestController#index (for 127.0.0.1 at 2008-05-21 09:46:16) [POST] Session ID: BAh7BzoMY3NyZl9pZCIlMDE2M2EyMzcyNmVlYTJiOTlmMmVjY2UxMTE3ODU4%0AZGQiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh %0Ac2h7AAY6CkB1c2VkewA%3D--bf05bf03237b9cc7db7b01626342d20037e77773 Parameters: {"commit"=>"Submit", "authenticity_token"=>"4eebcffb9f792f1422352b30f99e54c6e51411da", "action"=>"index", "controller"=>"test", "dump"=>{"dump"=>#<ActionController::UploadedStringIO:0x47b8140>}} [4;36;1mContact Delete all (0.140000) [0m [0;1mDELETE FROM contacts WHERE 1=1 [0m WARNING: Can''t mass-assign these protected attributes: id WARNING: Can''t mass-assign these protected attributes: id WARNING: Can''t mass-assign these protected attributes: id WARNING: Can''t mass-assign these protected attributes: id WARNING: Can''t mass-assign these protected attributes: id [4;35;1mSQL (0.172000) [0m [0mINSERT INTO contacts ("id","FirstName","LastName","email","created_at","updated_at") VALUES(NULL,''eve'',''kiti'',''trixieve-/E1597aS9LQAvxtiuMwx3w@public.gmane.org'',''2008-05-21 09:46:16'',''2008-05-21 09:46:16'') [0m TypeError (Array can''t be coerced into Fixnum): C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/ lib/ar-extensions/import.rb:272:in `+'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/ lib/ar-extensions/import.rb:272:in `import_without_validations_or_callbacks'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/ lib/ar-extensions/import.rb:262:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/ lib/ar-extensions/import.rb:262:in `import_without_validations_or_callbacks'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/ lib/ar-extensions/import.rb:243:in `import_with_validations'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/ar-extensions-0.7.0/ lib/ar-extensions/import.rb:202:in `import'' /app/controllers/test_controller.rb:14:in `index'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in `send'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in `perform_action_without_filters'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:697:in `call_filters'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:689:in `perform_action_without_benchmark'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/rescue.rb:199:in `perform_action_without_caching'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:678:in `perform_action'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/query_cache.rb:8:in `cache'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:677:in `perform_action'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in `send'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in `process_without_filters'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:685:in `process_without_session_management_support'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/session_management.rb:123:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:388:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:171:in `handle_request'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:115:in `dispatch'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:126:in `dispatch_cgi'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:9:in `dispatch'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/bin/../lib/mongrel/rails.rb:76:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/bin/../lib/mongrel/rails.rb:74:in `synchronize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/bin/../lib/mongrel/rails.rb:74:in `process'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:159:in `process_client'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:158:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:158:in `process_client'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:285:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:285:in `initialize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:285:in `new'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:285:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:268:in `initialize'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:268:in `new'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel.rb:268:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel/configurator.rb:282:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel/configurator.rb:281:in `each'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel/configurator.rb:281:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/bin/mongrel_rails:128:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/lib/mongrel/command.rb:212:in `run'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-x86- mswin32/bin/mongrel_rails:281 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:489:in `load'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:489:in `load'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:342:in `new_constants_in'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:489:in `load'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/ commands/servers/mongrel.rb:64 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `gem_original_require'' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `require'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:496:in `require'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:342:in `new_constants_in'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:496:in `require'' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/ commands/server.rb:39 C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `gem_original_require'' C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `require'' ./script/server:3 -e:2:in `load'' -e:2 Rendering C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/ lib/action_controller/templates/rescues/layout.erb (internal_server_error) --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hmm. Mabye you shouldn''t be importing actual AR instances? Have you read this article? http://www.jobwd.com/article/show/31 In it, the import is done by specifying matched arrays of columns and values (shown near the end just before the comments). Note that the docs for ar-extensions are still down (I notified the author awhile ago, but he''s been busy preparing for RailsConf). Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig, I''ve tried that as well... and it still gives the same error. I suspect it has to do with the NULL value being passed in for the id column (based on looking at the log). However, I am not doing anything to specify it so I don''t know why it''s doing that. BTW, Thank you for your effort so far On May 21, 10:07 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hmm. Mabye you shouldn''t be importing actual AR instances? Have you > read this article? > > http://www.jobwd.com/article/show/31 > > In it, the import is done by specifying matched arrays of columns and > values (shown near the end just before the comments). > > Note that the docs for ar-extensions are still down (I notified the > author awhile ago, but he''s been busy preparing for RailsConf). > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
So you''ve tried something like this and still see the same problem? if params[:dump][:dump] columns = [:FirstName, :LastName, :email] values = [] FasterCSV.parse(params[:dump][:dump].read.chop, {:headers =>true, :skip_blanks => true}) do |row| values << [ row["First Name"], row["Last Name"], row["Email Address"] ] end Contact.import columns, values end Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes. Infact, I had it practical identical to that On May 21, 10:20 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So you''ve tried something like this and still see the same problem? > > if params[:dump][:dump] > columns = [:FirstName, :LastName, :email] > values = [] > FasterCSV.parse(params[:dump][:dump].read.chop, {:headers =>true, > :skip_blanks => true}) do |row| > values << [ row["First Name"], row["Last Name"], row["Email Address"] ] > end > Contact.import columns, values > end > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What about versions of Ruby, Rails, ar-extensions, FasterCSV? What database and version of it are you using? What platform are you running? Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ruby 1.8, Rails 2.0.2, AR 0.7.0, FasterCSV is the latest version, Win XP, InstantRails, SQLite On May 21, 10:33 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What about versions of Ruby, Rails, ar-extensions, FasterCSV? What > database and version of it are you using? What platform are you > running? > > Craig--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Wed, May 21, 2008 at 1:36 PM, mel ram <melvin-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> > Ruby 1.8, Rails 2.0.2, AR 0.7.0, FasterCSV is the latest version, Win > XP, InstantRails, SQLiteI don''t have experience on Windows with InstantRails and SQLite. Are you able to try a different database, such as mysql? Are you able to try with Rails outside of InstantRails? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AR-extensions says its compatible with SQLite and instantrails is the same as regular rails so it wouldn''t have any effect on the problem. On May 21, 10:41 am, "Craig Demyanovich" <cdemyanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, May 21, 2008 at 1:36 PM, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > Ruby 1.8, Rails 2.0.2, AR 0.7.0, FasterCSV is the latest version, Win > > XP, InstantRails, SQLite > > I don''t have experience on Windows with InstantRails and SQLite. Are > you able to try a different database, such as mysql? Are you able to > try with Rails outside of InstantRails?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok I''ve simplified the code to try and identify what the heck is going on. I took out every except: contactx = [ Contact.new( :first_name =>"First 1", :last_name =>"Last 1", :email_address => "Email 1"), Contact.new( :first_name =>"First 2", :last_name =>"Last 2", :email_address => "Email 2")] Contact.import contactx And it still won''t work --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 21, 7:15 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> Ok I''ve simplified the code to try and identify what the heck is going > on. I took out every except: > > contactx = [ Contact.new( :first_name =>"First 1", :last_name > =>"Last 1", :email_address => "Email 1"), > Contact.new( :first_name =>"First > 2", :last_name =>"Last 2", :email_address => "Email 2")] > Contact.import contactx > > And it still won''t workIt''s a bug in ar-extensions. (and looking at the code it would seem they were relying on something that isn''t documented. The trunk version looks to have fixed this. Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The trunk version? How do I get that? On Wed, May 21, 2008 at 11:23 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On May 21, 7:15 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > Ok I''ve simplified the code to try and identify what the heck is going > > on. I took out every except: > > > > contactx = [ Contact.new( :first_name =>"First 1", :last_name > > =>"Last 1", :email_address => "Email 1"), > > Contact.new( :first_name =>"First > > 2", :last_name =>"Last 2", :email_address => "Email 2")] > > Contact.import contactx > > > > And it still won''t work > > It''s a bug in ar-extensions. (and looking at the code it would seem > they were relying on something that isn''t documented. The trunk > version looks to have fixed this. > > Fred > > >-- ~ mel Melvin Ram Volcanic Marketing www.volcanicmarketing.com Cell: 916.743.9369 Email: melvin-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org AIM: melvinram916 MSN Messenger: melvin_ram-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org Skype: melvinram --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I just installed ar-ext from http://arext.rubyforge.org/svn/trunk/ar-extensions/ and that didn''t change anything. Any other ideas? On May 21, 11:26 am, "Melvin Ram" <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> The trunk version? How do I get that? > > On Wed, May 21, 2008 at 11:23 AM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On May 21, 7:15 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > Ok I''ve simplified the code to try and identify what the heck is going > > > on. I took out every except: > > > > contactx = [ Contact.new( :first_name =>"First 1", :last_name > > > =>"Last 1", :email_address => "Email 1"), > > > Contact.new( :first_name =>"First > > > 2", :last_name =>"Last 2", :email_address => "Email 2")] > > > Contact.import contactx > > > > And it still won''t work > > > It''s a bug in ar-extensions. (and looking at the code it would seem > > they were relying on something that isn''t documented. The trunk > > version looks to have fixed this. > > > Fred > > -- > ~ mel > > Melvin Ram > Volcanic Marketingwww.volcanicmarketing.com > > Cell: 916.743.9369 > Email: mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org > AIM: melvinram916 > MSN Messenger: melvin_...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > Skype: melvinram--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 21, 7:26 pm, "Melvin Ram" <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> The trunk version? How do I get that? >It''s linked from the rubyforge project page. Fred> On Wed, May 21, 2008 at 11:23 AM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On May 21, 7:15 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > Ok I''ve simplified the code to try and identify what the heck is going > > > on. I took out every except: > > > > contactx = [ Contact.new( :first_name =>"First 1", :last_name > > > =>"Last 1", :email_address => "Email 1"), > > > Contact.new( :first_name =>"First > > > 2", :last_name =>"Last 2", :email_address => "Email 2")] > > > Contact.import contactx > > > > And it still won''t work > > > It''s a bug in ar-extensions. (and looking at the code it would seem > > they were relying on something that isn''t documented. The trunk > > version looks to have fixed this. > > > Fred > > -- > ~ mel > > Melvin Ram > Volcanic Marketingwww.volcanicmarketing.com > > Cell: 916.743.9369 > Email: mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org > AIM: melvinram916 > MSN Messenger: melvin_...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > Skype: melvinram--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I just installed ar-ext from http://arext.rubyforge.org/svn/trunk/ar-extensions/ and that didn''t change anything. Any other ideas? On May 21, 11:51 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 21, 7:26 pm, "Melvin Ram" <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> The trunk version? How do I get that? > > It''s linked from the rubyforge project page. > > Fred > > > On Wed, May 21, 2008 at 11:23 AM, Frederick Cheung < > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On May 21, 7:15 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > > Ok I''ve simplified the code to try and identify what the heck is going > > > > on. I took out every except: > > > > > contactx = [ Contact.new( :first_name =>"First 1", :last_name > > > > =>"Last 1", :email_address => "Email 1"), > > > > Contact.new( :first_name =>"First > > > > 2", :last_name =>"Last 2", :email_address => "Email 2")] > > > > Contact.import contactx > > > > > And it still won''t work > > > > It''s a bug in ar-extensions. (and looking at the code it would seem > > > they were relying on something that isn''t documented. The trunk > > > version looks to have fixed this. > > > > Fred > > > -- > > ~ mel > > > Melvin Ram > > Volcanic Marketingwww.volcanicmarketing.com > > > Cell: 916.743.9369 > > Email: mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org > > AIM: melvinram916 > > MSN Messenger: melvin_...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > > Skype: melvinram--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 21, 8:11 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> I just installed ar-ext fromhttp://arext.rubyforge.org/svn/trunk/ar-extensions/ > and that didn''t change anything. Any other ideas? >Seems unlikely that noting changed since your original error trace seems highly improbable with the trunk version of the software. what''s the backtrace now ? (are you certain it''s using the new code and not picking up the old gem?) Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
HOLY CRAP!!! IT''S ALIVE! I think it was picking up the old gem. I restarted the server and it worked! Thank you so much! On May 21, 12:16 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 21, 8:11 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> I just installed ar-ext fromhttp://arext.rubyforge.org/svn/trunk/ar-extensions/ > > and that didn''t change anything. Any other ideas? > > Seems unlikely that noting changed since your original error trace > seems highly improbable with the trunk version of the software. what''s > the backtrace now ? (are you certain it''s using the new code and not > picking up the old gem?) > > Fred--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ve sent Mel a preview of ar-extensions 0.8.0 gem as well. It looks like this fixes the issue. according to the past few messages. I will look into pushing out an official 0.8.0 gem at or after RailsConf, Zach Dennis http://www.contintuousthinking.com On May 21, 3:41 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> HOLY CRAP!!! IT''S ALIVE! > > I think it was picking up the old gem. I restarted the server and it > worked! Thank you so much! > > On May 21, 12:16 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On May 21, 8:11 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> I just installed ar-ext fromhttp://arext.rubyforge.org/svn/trunk/ar-extensions/ > > > and that didn''t change anything. Any other ideas? > > > Seems unlikely that noting changed since your original error trace > > seems highly improbable with the trunk version of the software. what''s > > the backtrace now ? (are you certain it''s using the new code and not > > picking up the old gem?) > > > Fred--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I believe that I need to do the same things you guys are discussing here. I need to import employee records from a CSV file. Although I have a little wrinkle in my project. Some of the employee records may already exist, in that case I need to update some of the database elements (hours worked, payrate, etc). I have the CSV file with headers and my database is all setup and currently being updated manually within a rails app. I think I am following your examples but am a little stuck on the FasterCSV params. Can you provide me with the exact code that is in your controller? Thanks, Norman Moore -- 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 -~----------~----~----~----~------~----~------~--~---
Below is the code from my experimental app. It''s not a production-level page. I was doing an experiment to figure out how to do this to scratch and itch <http://48hrlaunch.wordpress.com/2008/05/22/day-1-action-plan/>. ## controller/upload.rb class UploadController < ApplicationController require ''ar-extensions'' def index end def import_csv Contact.delete_all if params[:dump][:dump] contactx = [] FasterCSV.parse(params[:dump][:dump].read.chop, {:headers =>true,:skip_blanks => true}) do |row| contactx << Contact.new( :first_name => row["First Name"], :middle_name => row["Middle Address"], :last_name => row["Last Name"], :email_address => row["Email Address"], :job_title => row["Job Title"], :company => row["Company"], :work_phone => row["Work Phone"], :home_phone => row["Home Phone"], :address_line_1 => row["Address Line 1"], :address_line_2 => row["Address Line 2"], :city => row["City"], :us_state_ca_province => row["US State/CA Province"], :other_state_province => row["Other State/Province"], :country => row["Country"], :zip_postal_code => row["Zip/Postal Code"], :sub_zip_postal_code => row["Sub Zip/Postal Code"], :notes => row["Notes"], :custom_field_1 => row[" Custom field 1"], :custom_field_2 => row[" Custom field 2"], :custom_field_3 => row[" Custom field 3"], :custom_field_4 => row[" Custom field 4"], :custom_field_5 => row[" Custom field 5"], :custom_field_6 => row[" Custom field 6"], :custom_field_7 => row[" Custom field 7"], :custom_field_8 => row[" Custom field 8"], :custom_field_9 => row[" Custom field 9"], :custom_field_10 => row[" Custom field 10"], :custom_field_11 => row[" Custom field 11"], :custom_field_12 => row[" Custom field 12"], :custom_field_13 => row[" Custom field 13"], :custom_field_14 => row[" Custom field 14"], :custom_field_15 => row[" Custom field 15"] ) end Contact.import contactx end @contacts = Contact.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @contacts } end end end ## view/upload/index.html.erb <h1>Upload a data file</h1> <% form_for :dump, :url =>{:controller=>"upload", :action=>"import_csv"}, :html => { :multipart => "true" } do |f| -%> <table> <tr> <td> <label for="dump_file"> Select a CSV File : </label> </td> <td > <%= f.file_field :dump -%> </td> </tr> <tr> <td colspan="2"> <%= submit_tag "Submit" -%> </td> </tr> </table> <% end -%> ## view/upload/import_csv.html.erb <h1>Listing contacts</h1> <table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th> </tr> <% for contact in @contacts %> <tr> <td><%=h contact.first_name %></td> <td><%=h contact.last_name %></td> <td><%=h contact.email_address %></td> <td><%= link_to ''Show'', contact %></td> <td><%= link_to ''Edit'', edit_contact_path(contact) %></td> <td><%= link_to ''Destroy'', contact, :confirm => ''Are you sure?'', :method => :delete %></td> </tr> <% end %> </table> <br /> <%= link_to ''Upload new file'', :controller => :upload %> On Thu, May 22, 2008 at 9:20 AM, Norman Moore < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I believe that I need to do the same things you guys are discussing > here. I need to import employee records from a CSV file. Although I > have a little wrinkle in my project. Some of the employee records may > already exist, in that case I need to update some of the database > elements (hours worked, payrate, etc). I have the CSV file with headers > and my database is all setup and currently being updated manually within > a rails app. I think I am following your examples but am a little stuck > on the FasterCSV params. Can you provide me with the exact code that is > in your controller? > > Thanks, > Norman Moore > -- > Posted via http://www.ruby-forum.com/. > > > >-- ~ mel Melvin Ram Volcanic Marketing www.volcanicmarketing.com Cell: 916.743.9369 Email: melvin-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org AIM: melvinram916 MSN Messenger: melvin_ram-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org Skype: melvinram --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Melvin, I just wanted to be able to play with a few fields to see if I could get a few fields imported...it works perfectly! Now I know why I decided to develop in Rails. Thanks, Norm -- 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 -~----------~----~----~----~------~----~------~--~---
Yea, the community is pretty cool On May 22, 11:13 am, Norman Moore <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Melvin, > > I just wanted to be able to play with a few fields to see if I could get > a few fields imported...it works perfectly! Now I know why I decided to > develop in Rails. > > Thanks, > Norm > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---