Skip to content

Instantly share code, notes, and snippets.

@seamusabshere
Created September 22, 2010 21:17
Show Gist options
  • Select an option

  • Save seamusabshere/592591 to your computer and use it in GitHub Desktop.

Select an option

Save seamusabshere/592591 to your computer and use it in GitHub Desktop.
diff --git a/data_miner_test.rb b/data_miner_test.rb
index 69c9cd5..fca902c 100644
--- a/data_miner_test.rb
+++ b/data_miner_test.rb
@@ -4,12 +4,12 @@ class Shop < ActiveRecord::Base
end
class ItemDetail < ActiveRecord::Base
- set_primary_key :id
+ set_primary_key :row_hash
data_miner do
import 'A csv file with no identifier', :url => 'http://imports.s3.amazonaws.com/products_no_id.csv', :errata => 'http://spreadsheets.google.com/pub?key=tF58sAgqkY214EFBMdYCIUw', :delimiter => ';' do
# shop = Shop.find_by_user_id(98765)
- key 'id', :synthesize => lambda { |row| 0.upto(row.size) { |i| i } }
+ key 'row_hash'
store 'title', :field_name => 'Nome*'
store 'description', :field_name => 'Descrizione'
end
diff --git a/test_helper.rb b/test_helper.rb
index aa13e07..6791919 100644
--- a/test_helper.rb
+++ b/test_helper.rb
@@ -1,5 +1,6 @@
ActiveRecord::Schema.define(:version => 20090819143429) do
- create_table 'item_details', :force => true, :options => 'ENGINE=InnoDB default charset=utf8' do |t|
+ create_table 'item_details', :force => true, :options => 'ENGINE=InnoDB default charset=utf8', :id => false do |t|
+ t.string 'row_hash'
t.string "title", :limit => 64
t.text "description", :limit => 2147483647
t.integer "duration", :default => 15
@seamusabshere

Copy link
Copy Markdown
Author

in line 27 above, note that I added ":id => false"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment