问题标签 [chewy-gem]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
44 浏览

ruby-on-rails - 将 toptal/chewy gem 与 ankane/strong_migration gem 一起使用时发生冲突

ankane/strong_migrationgem 与toptal/chewy gem.

两个 gem 都重写了 Active Support 的方法 migrate,导致我运行时 migrate 函数中的无限循环rake db:migrate

以下是错误消息:

如果有人解决了这个问题,请帮助我。谢谢!

0 投票
2 回答
239 浏览

elasticsearch - ElasticSearch:升级 Chewy/ElasticSearch 版本时出错

我一直在我的 rails 应用程序中使用 gem咀嚼,在 ElasticSearch 中创建索引和搜索。之前我用的是elasticsearch 5.6版本,现在想升级到7.7。当我尝试创建索引时,出现以下错误。我正在使用的升级版耐嚼5.1.0

但是,它在 5.6 中运行得非常好。我试图在耐嚼中找到任何更改日志,但找不到任何更改日志。请帮助我了解问题出在哪里。谢谢

0 投票
0 回答
231 浏览

ruby-on-rails - Puma 发现了这个错误:nil:NilClass (NoMethodError) 的未定义方法 `first'

Puma 发现了这个错误:使用弹性搜索服务的 nil:NilClass (NoMethodError) 的未定义方法 `first'。
当记录更新然后这个问题

ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader/association.rb:105:in block in records_for' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/core.rb:361:in init_with_attributes' ruby​​-2.7.2/rails-6.0.3.4/gems /activerecord-6.0.3.4/lib/active_record/persistence.rb:403:in instantiate_instance_of' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/querying.rb:61:in block (2 levels) in find_by_sql' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/ result.rb:62:in block in each' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/result.rb:62:in each' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/result.rb:62:in each' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/querying.rb:61:in map' ruby​​-2.7.2/rails- 6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/querying.rb:61:in block in find_by_sql' ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb:24:in instrument' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/querying .rb:56:infind_by_sql' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:821:in 块在 exec_queries 的 ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:839:inskip_query_cache_if_necessary' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:808:in exec_queries' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:626:in load' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader/association.rb:102:in records_for' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord -6.0.3.4/lib/active_record/associations/preloader/association.rb:41:in preloaded_records' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader/association.rb:32:in records_by_owner' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader/ Association.rb:18:in block in run' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader/association.rb:17:in each' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader/association.rb:17:in run' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:145:in block in preloaders_for_reflection' ruby ​​- 2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:144:in each' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:144:in map' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0 .3.4/lib/active_record/associations/preloader.rb:144:inpreloaders_for_reflection' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:113:in preloaders_for_hash' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:112:in each' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:112:in flat_map' ruby ​​-2.7.2/rails 中的块(2 级) -6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:112:in block in preloaders_for_hash' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:111:in each' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/ active_record/associations/preloader.rb:111:in flat_map' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:111:in preloaders_for_hash' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:102:in preloaders_on' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:92:in block in preload' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:91:in each' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/associations/preloader.rb:91:in flat_map' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord -6.0.3.4/lib/active_record/associations/preloader.rb:91:inpreload' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:745:in 在 preload_associations 的 ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:743 中的块:在each' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:743:in preload_associations 的 ruby​​-2.7.2/rails-6.0.3.4/gems /activerecord-6.0.3.4/lib/active_record/relation.rb:824:in block in exec_queries' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:839:in skip_query_cache_if_necessary' ruby​​-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:808:在exec_queries' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:626:in 加载'ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation.rb:250:in records' ruby-2.7.2/rails-6.0.3.4/gems/activerecord-6.0.3.4/lib/active_record/relation/delegation.rb:87:in each'ruby-2.7.2/rails-6.0.3.4/bundler/ gems/chewy-c91c6842b3e4/lib/chewy/type/adapter/orm.rb:129:in block in import_objects' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/adapter/orm.rb:119:in each' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/adapter /orm.rb:119:in each_slice' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/adapter/orm.rb:119:in each' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/adapter/orm.rb:119:inmap' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/adapter/orm.rb:119:in import_objects' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/adapter/orm.rb:81:in import' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/import.rb:142:in block in import_linear' ruby​​-2.7.2/rails-6.0 .3.4/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:inblock in instrument' ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb:24:in 仪器'ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/notifications。 rb:180:in instrument' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/import.rb:141:in import_linear'ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/import.rb:136:in import_routine' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/type/import.rb:87:in import!' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/strategy/atomic.rb:25:in block in leave' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/strategy/atomic.rb:25:in each' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems /chewy-c91c6842b3e4/lib/chewy/strategy/atomic.rb:25:in all?' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/strategy/atomic.rb:25:in leave' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/strategy.rb:63:在tap' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/strategy.rb:63:in pop' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy/strategy.rb:72:in wrap' ruby-2.7.2/rails-6.0.3.4/bundler/gems/chewy-c91c6842b3e4/lib/chewy.rb:201:in strategy' ruby​​-2.7.2/rails-6.0.3.4/bundler/gems /chewy-c91c6842b3e4/lib/chewy/railtie.rb:19:in call' ruby-2.7.2/rails-6.0.3.4/gems/railties-6.0.3.4/lib/rails/rack/logger.rb:37:in call_app' ruby​​-2.7.2/rails-6.0.3.4/gems/railties-6.0.3.4/lib/rails/rack/logger.rb:26:在block in call' ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/tagged_logging.rb:80:in 标记'ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/tagged_logging.rb:28:intagged' ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/tagged_logging.rb:80:in 标记'ruby-2.7.2/rails-6.0.3.4/中的块中gems/railties-6.0.3.4/lib/rails/rack/logger.rb:26:in call' ruby-2.7.2/rails-6.0.3.4/gems/sprockets-rails-3.2.2/lib/sprockets/rails/quiet_assets.rb:13:in call' ruby​​-2.7.2/rails-6.0.3.4/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/remote_ip .rb:81:in call' ruby-2.7.2/rails-6.0.3.4/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/request_id.rb:27:in call' ruby​​-2.7.2/rails-6.0.3.4/gems/rack-2.2.3/lib/rack/method_override.rb:24:incall' ruby-2.7.2/rails-6.0.3.4/gems/rack-2.2.3/lib/rack/runtime.rb:22:in 调用'ruby-2.7.2/rails-6.0.3.4/gems/activesupport-6.0.3.4/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call'ruby call' ruby-2.7.2/rails-6.0.3.4/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/executor.rb:14:in -2.7.2/rails-6.0.3.4 /gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in call' ruby-2.7.2/rails-6.0.3.4/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in call' ruby​​-2.7.2/rails-6.0.3.4/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/ host_authorization.rb:82:in call' ruby-2.7.2/rails-6.0.3.4/gems/webpacker-5.2.1/lib/webpacker/dev_server_proxy.rb:25:in perform_request' ruby​​-2.7.2/rails-6.0.3.4/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in call' ruby-2.7.2/rails-6.0.3.4/gems/railties-6.0.3.4/lib/rails/engine.rb:527:in call' ruby​​-2.7.2/ rails-6.0.3.4/gems/puma-5.1.0/lib/puma/configuration.rb:246:in call' ruby-2.7.2/rails-6.0.3.4/gems/puma-5.1.0/lib/puma/request.rb:76:in block in handle_request' ruby​​-2.7.2/rails-6.0.3.4/gems/puma-5.1.0/lib /puma/thread_pool.rb:337:in with_force_shutdown' ruby-2.7.2/rails-6.0.3.4/gems/puma-5.1.0/lib/puma/request.rb:75:in handle_request' ruby​​-2.7.2/rails-6.0.3.4/gems/puma-5.1.0/lib/puma/server.rb:431:in process_client' ruby-2.7.2/rails-6.0.3.4/gems/puma-5.1.0/lib/puma/thread_pool.rb:145:in block in spawn_thread'

0 投票
1 回答
43 浏览

ruby-on-rails - 当我删除产品表中的产品时,productIndex 不会更新

当我删除产品表中的产品时,productIndex 不会更新。

My Query:

Product.friendly.where(slug: params[:id]).first.destroy_fully!

Model:

类产品 < 应用记录

act_as_paranoid #用于软删除

扩展 FriendlyId #slug

friendly_id :name, 使用: :slugged

update_index('products#product') { 自我 }

结尾

Chewy library:

define_type Product.includes(:brand, product_images_attachments: :blob) do field :id field :name field :name field :slug end end

GemFile

宝石'活动管理员'

宝石'acts_as_paranoid'

宝石'email_validator'

gem 'friendly_id', '~> 5.4.0'

宝石'耐嚼',git:'https://github.com/abdullah5514/chewy.git'

宝石'active_model_serializers'

0 投票
0 回答
48 浏览

ruby-on-rails - Elasticsearch 在 localhost 中运行良好,但在测试时出现连接错误

我是 Elasticsearch 和 Docker 的新手。我正在使用我的应用程序获取搜索结果,但是当我对相同的应用程序运行测试时,我遇到了这样的连接错误

我正在使用chewy gemofruby on rails来实现Elasticsearch

这是搜索的示例代码

我正在测试使用Rspec 注意搜索在应用程序中运行良好。运行测试文件时出现此错误

0 投票
0 回答
33 浏览

ruby-on-rails - ActiveRecord::StatementInvalid: PG::ConnectionBad: 在迁移过程中连接关闭

好的。我下载了这个社交网络服务器以在我的机器上进行本地测试,我已按照所有说明进行操作,但缺少迁移。

我一次又一次地进行迁移(命令是bundle exec rake db:migrate RAILS_ENV=development),我不断收到这个错误,看起来chewy图书馆是问题所在。或者其他什么,我以前从未使用过 Rails。

这些是我得到的日志的最后几行:

随后,当我再次尝试进行迁移时,出现此错误:

我尝试删除用于测试和开发的数据库,然后回到第一条消息。(注意:我直接从 psql 中删除,因为 rake 命令也不起作用)

在设置服务器之前没有进行任何迁移foreman start

这又是命令的结果bundle exec rake db:create

我使用的软件版本是:

  • 红宝石 2.5.1p57
  • 导轨 5.2.3
  • 耐嚼的宝石 5.0.0(我猜)
  • Node.js v10.24.1
  • PostgreSQL 10.18

除此之外,我什么都没试过,我不知道如何继续。