Answer the question
In order to leave comments, you need to log in
Why is the Rails gem activerecord-import not saving records to the database?
Hello
I'm using Rail 3.2.13 , gem version 0.3.1. MySQL DB. Gem decided to use it to store a large number of records in the database at a time. About 200 thousand. I decided to test from the console first.
Loading development environment (Rails 3.2.13)
1.9.3-p448 :001 > statuses = [Status.new(name: 'test1'), Status.new(name: 'test2')]
=> [#<Status id: nil, name: "test1", validity: true, created_at: nil, updated_at: nil, info: nil>, #<Status id: nil, name: "test2", validity: true, created_at: nil, updated_at: nil, info: nil>]
1.9.3-p448 :002 > Status.import statuses
Status Exists (0.3ms) SELECT 1 AS one FROM `statuses` WHERE `statuses`.`name` = 'test1' LIMIT 1
Status Exists (0.2ms) SELECT 1 AS one FROM `statuses` WHERE `statuses`.`name` = 'test2' LIMIT 1
(0.4ms) SHOW VARIABLES like 'max_allowed_packet';
Class Create Many Without Validations Or Callbacks (0.3ms) INSERT INTO `statuses` (`id`,`name`,`validity`,`created_at`,`updated_at`,`info`) VALUES (NULL,'test1',1,'2014-08-27 11:36:59','2014-08-27 11:36:59',NULL),(NULL,'test2',1,'2014-08-27 11:36:59','2014-08-27 11:36:59',NULL) ON DUPLICATE KEY UPDATE `statuses`.`updated_at`=VALUES(`updated_at`)
=> #<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=1>
1.9.3-p448 :003 > Status.all
Status Load (0.3ms) SELECT `statuses`.* FROM `statuses`
=> [#<Status id: 1, name: "test1", validity: true, created_at: "2014-08-27 07:36:59", updated_at: "2014-08-27 07:36:59", info: nil>, #<Status id: 2, name: "test2", validity: true, created_at: "2014-08-27 07:36:59", updated_at: "2014-08-27 07:36:59", info: nil>]
1.9.3-p448 :011 > Status.create(name: 'test3')
Answer the question
In order to leave comments, you need to log in
Unknown column 'status' in 'where clause'Which of the words in this sentence can't you translate from English yourself?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question