我是Ruby on Rails的新手。现在,当我尝试运行Spree电子商务平台时,我遇到了从CSV文件导入产品的问题。
从CSV导入产品," datashift"和" datashift_spree"正在使用宝石。
顺便说一下,当我运行" bundle exec thor datashift_spree:load:products -v -i ./sample_csv/SpreeMultiVariant.csv"在Ubuntu shell上。
DataShift::Product starting upload from file: ./sample_csv/SpreeMultiVariant.csv
["sku", "name", "price"]
["sku", "name", "description", "available_on", "price", "tax_category", "shipping_category", "cost_price", "variants", "variants", "variants", "product_properties", "taxons", "taxons", "taxons", "stock_items", "images", "variant_images"]
Loading from CSV file: ./sample_csv/SpreeMultiVariant.csv
Processing 3 rows
Failed to process row [1] (["PIKS-001", "Demo Product for AR Loader", "blah blah", "02/10/16", "399.99", "VAT", "small", "320", "mime_type:jpeg, PDF;print_type:colour", nil, "mime_type:PNG", "test_pp_001", "Paintings>Landscape", "WaterColour", nil, "12|6|7", "https://github.com/pikender/datashift_spree/raw/master/spec/fixtures/images/spree.png", nil])
#<NoMethodError: undefined method `type_cast_from_database' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x0055e71e56eae0>>
Failed to process row [2] (["PIKS-002", "Demo Excel Load via Jruby", "less blah", "03/10/16", "100", "Sales Tax", "medium", "30", "mime_type:jpeg;print_type:black_white", nil, "mime_type:PNG;print_type:black_white", "test_pp_003", "Paintings", "Oils", "Paintings>Nature>Landscape", "Delhi:5|Bombay:4", nil, "https://github.com/pikender/datashift_spree/raw/master/spec/fixtures/images/DEMO_001_ror_bag.jpeg|https://github.com/pikender/datashift_spree/raw/master/spec/fixtures/images/DEMO_004_ror_ringer.jpeg"])
#<NoMethodError: undefined method `type_cast_from_database' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x0055e71e56eae0>>
Failed to process row [3] (["PIKS-003", "Demo third row in future", "more blah blah", "04/12/12", "50.34", "Entertainment Tax", "large", "23.34", "mime_type:jpeg;print_type:colour, sepia;size:large|mime_type:PNG", "mime_type:PDF|print_type:black_white", nil, "test_pp_002|test_pp_003:Example free value|yet_another_property", "Drawings>Landscape", "Landscape", "Paintings>Nature>Seascape>Cliffs", "12|4|7|12|2", "https://github.com/pikender/datashift_spree/raw/master/spec/fixtures/images/DEMO_003_ror_mug.jpeg", nil])
#<NoMethodError: undefined method `type_cast_from_database' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x0055e71e56eae0>>
Processing Summary Report
>>>>>>>>>>>>>>>>>>>>>>>>>
Processed total of 3 inbound entries
0 database objects were successfully processed.
0 inbound rows were successfully processed.
WARNING : Check logs : 3 rows contained errors
我不知道为什么会这样。
我的Gemfile:
source 'https://rubygems.org'
gem 'rake', '~> 12.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails', '~> 4.1'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass', '~> 3.3.6'
gem 'font-awesome-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'spree', '~> 3.2.0'
gem 'spree_auth_devise', '~> 3.2.0'
gem 'spree_gateway', '~> 3.2.0'
gem 'datashift', :git => 'https://github.com/vinsol-spree-contrib/datashift', branch: '0-16-stable'
gem 'datashift_spree', :git => 'https://github.com/vinsol-spree-contrib/datashift_spree', branch: 'shopify/tmp'
gem 'spree_datashift_prod_import', :git => 'https://github.com/vinsol-spree-contrib/spree_datashift_prod_import'
答案 0 :(得分:0)
我有同样的错误。后来我发现在Rails 4.2中type_cast
更改为type_cast_from_database
这是链接:https://github.com/zdennis/activerecord-import/pull/169