首页 > 解决方案 > Hyperstack 中的“未初始化常量”错误:找不到模型和组件

问题描述

这是一个奇怪的错误,因为上周一切正常。今天当我想以开发模式启动应用程序时,我收到多个“名称错误”,说找不到某些类。

我有一个名为“index.rb”的组件文件,内容如下:

class Index < HyperComponent
  render do
    TABLE do
      THEAD do
        TR do
          TD { "ID" }
          # some other TD elements
        end
      end
      TBODY do
        SearchRequest.each do |search_request|
          SearchRequestItem(search_request: search_request)
        end
      end
    end
  end
end

现在我突然收到这个错误信息:uninitialized constant Index::SearchRequest. SearchRequest是一个模型。没有组件Index::SearchRequest。它上周工作,但突然出现了。

有任何想法吗?:)

提前致谢

更新:我在控制台中看到的第一条错误消息是:

Uncaught $NameError
message: "wrong constant name configuration"
stack: "wrong constant name configuration↵    at module_constructor.TMP_Opal_const_name$B_13 [as $const_name!] (http://0.0.0.0:5000/assets/corelib/helpers.self-12819e26a0290805599453b792fbf0f79a851b1f41aec5b8b47882438d7488a6.js?body=1:153:14)↵    at singleton_class_alloc.TMP_Module_const_defined$q_25 [as $const_defined?] (http://0.0.0.0:5000/assets/corelib/module.self-5472617930a9290fbc25a43d92197430a9f2f23359e95519f0448e3c43a41193.js?body=1:371:71)↵    at singleton_class_alloc.$$method_missing [as $method_missing] (http://0.0.0.0:5000/assets/hyperstack/component/native_library.self-75535a84993c140838a291f5280afa5c8027bc47f30991308163acb8bf6b7159.js?body=1:83:48)↵    at singleton_class_alloc.method_missing_stub [as $configuration] (http://0.0.0.0:5000/assets/corelib/runtime.self-a59b72816f596f5bb11f5da568edd0b684eec56ddaff0ae5da9834528996763d.js?body=1:1197:35)↵    at Opal.modules.models/application_record (http://0.0.0.0:5000/assets/models/application_record.self-58a416171d848eb64cec39146f35ea6fe61a97c774407ec8af7b6152798886ee.js?body=1:10:133)↵    at Object.Opal.load (http://0.0.0.0:5000/assets/corelib/runtime.self-a59b72816f596f5bb11f5da568edd0b684eec56ddaff0ae5da9834528996763d.js?body=1:2192:7)↵    at Object_alloc.Opal.require [as $require] (http://0.0.0.0:5000/assets/corelib/runtime.self-a59b72816f596f5bb11f5da568edd0b684eec56ddaff0ae5da9834528996763d.js?body=1:2216:17)↵    at Opal.modules.hyperstack-loader-application (http://0.0.0.0:5000/assets/hyperstack-loader-application.self-382c06b870470bd068dbf8a33536e9fdd371413f8b450880cf33e931fafc530c.js?body=1:22:8)↵    at Object.Opal.load (http://0.0.0.0:5000/assets/corelib/runtime.self-a59b72816f596f5bb11f5da568edd0b684eec56ddaff0ae5da9834528996763d.js?body=1:2192:7)↵    at http://0.0.0.0:5000/assets/hyperstack-loader.self-55b4fc5e1a9419c2c6574d3d23240bc19ca6c327d2bc43f3d74afaf673c5da68.js?body=1:5:6"

在上述错误之后,我还看到了几个错误,例如:

HyperStack autoloader failed attempting to load Object::ApplicationRecord.  Could be a bug in autoloader

HyperStack autoloader failed attempting to load Object::SearchRequest.  Could be a bug in autoloader

HyperStack autoloader failed attempting to load Object::ApplicationRecord.  Could be a bug in autoloader

HyperStack autoloader failed attempting to load Object::User.  Could be a bug in autoloader

HyperStack autoloader failed attempting to load Object::SearchRequest.  Could be a bug in autoloader

Uncaught $NameErrormessage: "uninitialized constant SearchRequestForm::SearchRequest"name: "SearchRequest"stack: "SearchRequest: uninitialized constant SearchRequestForm::SearchRequest"

HyperStack autoloader failed attempting to load Object::SearchRequest.  Could be a bug in autoloader

标签: ruby-on-railshyperstack

解决方案


推荐阅读