我在Ruby on Rails应用程序上使用Spree,我遇到以下错误
ActiveRecord::StatementInvalid in Spree::Admin::ProductsController#create
PG::NotNullViolation: ERROR: null value in column "name" violates not-null constraint DETAIL: Failing row contains (12, null, null, null, null, null, null, null, null, 1, 2018-05-15 08:58:58.830082, 2018-05-15 08:58:58.830082, t, null, null). : INSERT INTO "spree_products" ("name", "shipping_category_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"
log(sql, name, type_casted_binds, stmt_key) do
@connection.exec_prepared(stmt_key, type_casted_binds.map { |_, val| val })
end
rescue ActiveRecord::StatementInvalid => e
pgerror = e.original_exception
现在我不确定导致此问题的原因或解决方法。
我假设它与spree_globalize
宝石有关。
我试图卸载gem,但后来我得到错误后端spree_globalize
任何人都知道如何解决这个问题?
这是日志文件:
Started POST "/store/admin/products" for 213.127.86.174 at 2018-05-15 08:58:58 +0000
Cannot render console from 213.127.86.174! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Spree::Admin::ProductsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"v==", "product"=>{"name"=>"Volks", "sku"=>"", "prototype_id"=>"", "price"=>"29", "available_on"=>"", "shipping_category_id"=>"1"}, "button"=>""}
Spree::Preference Load (0.5ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1 [["key", "spree/backend_configuration/locale"]]
Spree::User Load (0.7ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 ORDER BY "spree_users"."id" ASC LIMIT 1 [["id", 1]]
Spree::Role Load (0.8ms) SELECT "spree_roles".* FROM "spree_roles" INNER JOIN "spree_role_users" ON "spree_roles"."id" = "spree_role_users"."role_id" WHERE "spree_role_users"."user_id" = $1 [["user_id", 1]]
(0.3ms) BEGIN
Spree::Product Exists (2.0ms) SELECT 1 AS one FROM "spree_products" INNER JOIN "friendly_id_slugs" ON "friendly_id_slugs"."sluggable_id" = "spree_products"."id" AND "friendly_id_slugs"."deleted_at" IS NULL AND "friendly_id_slugs"."sluggable_type" = $1 WHERE ("spree_products"."id" IS NOT NULL) AND "spree_products"."slug" = 'volks' LIMIT 1 [["sluggable_type", "Spree::Product"]]
Spree::Product Exists (0.6ms) SELECT 1 AS one FROM "spree_products" INNER JOIN "friendly_id_slugs" ON "friendly_id_slugs"."sluggable_id" = "spree_products"."id" AND "friendly_id_slugs"."deleted_at" IS NULL AND "friendly_id_slugs"."sluggable_type" = $1 WHERE ("spree_products"."id" IS NOT NULL) AND "spree_products"."slug" = 'volks' LIMIT 1 [["sluggable_type", "Spree::Product"]]
Spree::ShippingCategory Load (0.5ms) SELECT "spree_shipping_categories".* FROM "spree_shipping_categories" WHERE "spree_shipping_categories"."id" = $1 LIMIT 1 [["id", 1]]
Spree::Product::Translation Load (1.7ms) SELECT DISTINCT locale FROM "spree_product_translations" ORDER BY "spree_product_translations"."locale" ASC
Spree::Product Exists (0.8ms) SELECT DISTINCT 1 AS one FROM "spree_products" INNER JOIN "spree_product_translations" ON "spree_product_translations"."spree_product_id" = "spree_products"."id" WHERE 1=0 AND ("spree_product_translations"."slug" = 'volks-f405f8ca-e79d-4bbb-ba8a-63f80a13318a' AND "spree_product_translations"."deleted_at" IS NULL AND "spree_product_translations"."locale" = 'en') LIMIT 1
SQL (1.7ms) INSERT INTO "spree_products" ("name", "shipping_category_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [[nil, nil], ["shipping_category_id", 1], ["created_at", "2018-05-15 08:58:58.830082"], ["updated_at", "2018-05-15 08:58:58.830082"]]
(0.2ms) ROLLBACK
Completed 500 Internal Server Error in 49ms (ActiveRecord: 9.7ms)
的Gemfile
source 'https://rubygems.org
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
gem 'pg', '< 1'
# 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'
# 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 'rake'
gem 'rspec'
gem 'kramdown'
gem 'thor', '0.19.1'
gem 'spree_braintree_vzero', github: 'spree-contrib/spree_braintree_vzero'
# 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'
gem 'capistrano-passenger'
gem 'capistrano-rails'
gem 'capistrano-rvm'
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.1.0.rc1'
gem 'spree_auth_devise', '~> 3.1.0.rc1'
gem 'spree_gateway', '~> 3.1.0.rc1'
gem 'devise'
gem 'materialize-sass'
gem 'active_link_to'
gem 'mollie-api-ruby', '< 3.2'
# gem 'spree_mollie', github: 'salman15/mollie_spree_2017', branch: 'stable'
gem 'spree_mollie', github: 'ttcremers/spree_mollie', branch: 'stable'
gem 'spree_mail_settings', github: 'spree-contrib/spree_mail_settings'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize', branch: 'master'
gem "mini_magick"
# gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'rails-4-x' # For 4.x
# gem 'globalize', '~> 5.1.0'
答案 0 :(得分:0)
我从spree_globalize
文件中删除了Gemfile.lock
,然后删除了spree_globalize
错误停止发生。