根據本指南,我正在通過創建一個簡單的博客應用程式來學習 Rails 的基礎知識 - https://guides.rubyonrails.org/v6.1/getting_started.html
當我嘗試使用 運行服務器ruby bin\rails server時,服務器成功啟動localhost:3000,但是當我在瀏覽器中打開它時出現以下錯誤:-
Puma caught this error: uninitialized constant Pers
constant.const_get(name)
^^^^^^^^^^ (NameError)
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/inflector/methods.rb:286:in `const_get'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/inflector/methods.rb:286:in `block in constantize'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/inflector/methods.rb:284:in `each'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/inflector/methods.rb:284:in `inject'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/inflector/methods.rb:284:in `constantize'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/abstract_controller/helpers.rb:176:in `block in modules_for_helpers'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/abstract_controller/helpers.rb:169:in `map!'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/abstract_controller/helpers.rb:169:in `modules_for_helpers'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/metal/helpers.rb:104:in `modules_for_helpers'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.4.6/lib/rails/engine.rb:507:in `helpers'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.4.6/lib/rails/railtie.rb:207:in `public_send'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.4.6/lib/rails/railtie.rb:207:in `method_missing'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actiontext-6.1.4.6/lib/action_text/engine.rb:46:in `block (3 levels) in <class:Engine>'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:51:in `each'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/base.rb:270:in `<class:Base>'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/base.rb:166:in `<module:ActionController>'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/base.rb:7:in `<main>'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_dispatch/middleware/static.rb:171:in `each_candidate_filepath'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_dispatch/middleware/static.rb:100:in `find_file'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_dispatch/middleware/static.rb:68:in `attempt'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_dispatch/middleware/static.rb:24:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_dispatch/middleware/host_authorization.rb:119:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-mini-profiler-2.3.4/lib/mini_profiler/profiler.rb:393:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/webpacker-5.4.3/lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-proxy-0.7.2/lib/rack/proxy.rb:67:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-6.1.4.6/lib/rails/engine.rb:539:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/configuration.rb:252:in `call'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/request.rb:77:in `block in handle_request'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/request.rb:76:in `handle_request'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/server.rb:441:in `process_client'
C:/PROGRA~1/Ruby31-x64/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
幾天前,我遇到了同樣的錯誤 - uninitialized constant Pers,但我遵循了不同的指南并創建了不同的應用程式。
請注意,當我嘗試生成應用程式時,我tzinfo-data都遇到了必須使用此解決方案手動解決的問題 - https://stackoverflow.com/a/54227934/8936298
版本:-
Rails - 6.1.4.6
Ruby - 3.1.1p18 (2022-02-18 revision 53f5fc4236)
Yarn - 1.22.17
Node - v16.14.0
uj5u.com熱心網友回復:
解決方案:-
顯然,與版本存在沖突。正如 Abhinay 在評論中提到的,我切換到 Ruby 2.7.5,應用程式開始作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/437160.html
標籤:轨道上的红宝石 红宝石 彪马 ruby-on-rails-6.1
上一篇:如何使用RailsminiTest創建新書并為其分配兩個作者?
下一篇:找到兩個網格之間角度的最佳方法?
