【问题标题】:A copy of ApplicationHelper has been removed from the module tree but is still active?ApplicationHelper 的副本已从模块树中删除但仍处于活动状态?
【发布时间】:2011-11-28 14:17:51
【问题描述】:

我正在使用 rails 2.3.4 和 ruby​​ 1.8.7。 在我的应用程序中,当我尝试通过移动 Api 购买商品(这是一个金属请求)时,购买成功,现在当我进入 Web 界面并在实体中进行任何更改(如购买限制或商品价格)然后尝试再次通过手机api购买,报错

A copy of ApplicationHelper has been removed from the module tree but is still active!

[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/dependencies.rb:414:in `load_missing_constant'

[RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing_not_from_s3_library'

/home/user/.rvm/gems/ruby-1.8.7-p334/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'

[RAILS_ROOT]/app/helpers/web_application_helper.rb:414:in `purchases_left'

[RAILS_ROOT]/app/helpers/web_application_helper.rb:83:in `accept_purchase_direct'

[RAILS_ROOT]/lib/api/publisher/v1_purchases_helper.rb:49:in `purchases_handler'

[RAILS_ROOT]/app/metal/v1_purchases_controller.rb:54:in `call'

[RAILS_ROOT]/vendor/rails/railties/lib/rails/rack/metal.rb:44:in `call'

[RAILS_ROOT]/vendor/rails/railties/lib/rails/rack/metal.rb:43:in `each'

[RAILS_ROOT]/vendor/rails/railties/lib/rails/rack/metal.rb:43:in `call'

[RAILS_ROOT]/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:122:in `call'.

我在网上四处寻找,因为没有人遇到过同样的问题,但找不到相同的修复程序。现在当服务器重新启动并尝试购买时,它成功了。我不知道原因,但仍然想提出我的想法,如果在每次操作后我们连接到数据库,因为从进行数据库查询的行抛出错误,是否可以修复:

def purchases_left 
  accepted = AcceptedOffer.find_all_by_offer_id_and_user_id(offer.id, current_user.id)
end

我已经打印了报价的价值,并且是正确的。我想不出还有什么代码可以放。欢迎任何查询。

【问题讨论】:

    标签: ruby-on-rails ruby


    【解决方案1】:

    在开发模式下发生错误,因为缓存设置为 false,因此在至少在开发模式下将缓存设置为 true 后,不会发生错误但会发生查询缓存,因此您需要对其进行处理。也在我的调用下一个操作后未加载类的金属请求。 在生产的情况下,会发生查询缓存,而在此模式下不会出现错误,但结果不如预期,因为数据库中的更改没有反映出来。 所以在这两种情况下,我或我的解决方案都是绕过查询缓存。

    【讨论】:

      猜你喜欢
      • 2013-07-07
      • 2013-09-24
      • 2015-06-20
      • 1970-01-01
      • 2018-10-09
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      相关资源
      最近更新 更多