gpt4 book ai didi

ruby-on-rails - NameError : undefined local variable or method `app' for - Rails 5. 1.6升级

转载 作者:行者123 更新时间:2023-12-05 03:03:53 25 4
gpt4 key购买 nike

我在 rspec 中遇到了这个错误,而我没有任何具有该名称的变量或方法,我什至在整个项目中进行了搜索。当我为所有测试用例运行 Rspec,而单个测试用例工作正常时,会发生这种情况。

我正在将 ruby​​ on rails 版本从 ruby​​ 2.3.3 rails 4.1.6 升级。我一个一个地升级了版本,在使用 ruby​​ 2.4.5 达到 rails 5.1.6 后我已经通过了所有测试我得到了这个错误。而所有测试在相同的 ruby​​ 版本和 rails 5.0.7 下也能正常工作

如果您知道如何解决这个问题,请告诉我。

我再次使用 bin/rspec --init 重建了 spec_helper.rb 并添加了依赖项,现在我有了更长的跟踪

NameError:
undefined local variable or method `app' for #<Devise::Mailer:0x00007fd3271928f8>
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/rack-test-1.1.0/lib/rack/test/methods.rb:30:in `build_rack_mock_session'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/rack-test-1.1.0/lib/rack/test/methods.rb:26:in `rack_mock_session'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/rack-test-1.1.0/lib/rack/test/methods.rb:41:in `build_rack_test_session'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/rack-test-1.1.0/lib/rack/test/methods.rb:37:in `rack_test_session'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/rack-test-1.1.0/lib/rack/test/methods.rb:45:in `current_session'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/helpers/controller_helper.rb:18:in `assign_controller'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/base.rb:211:in `initialize'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionpack-5.1.6/lib/action_dispatch/routing/url_for.rb:106:in `initialize'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/rendering.rb:72:in `new'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/rendering.rb:72:in `view_context'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/rendering.rb:97:in `_render_template'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/rendering.rb:83:in `render_to_body'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionpack-5.1.6/lib/abstract_controller/rendering.rb:24:in `render'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:945:in `block in collect_responses_from_templates'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:942:in `each'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:942:in `each'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:942:in `map'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:942:in `collect_responses_from_templates'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:927:in `collect_responses'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:830:in `mail'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/devise-4.5.0/lib/devise/mailers/helpers.rb:19:in `devise_mail'
# ./app/mailers/devise/mailer.rb:12:in `confirmation_instructions'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionpack-5.1.6/lib/abstract_controller/base.rb:186:in `process_action'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionpack-5.1.6/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:97:in `run_callbacks'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionpack-5.1.6/lib/abstract_controller/callbacks.rb:19:in `process_action'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionpack-5.1.6/lib/abstract_controller/base.rb:124:in `process'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/rescuable.rb:23:in `block in process'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/rescuable.rb:15:in `handle_exceptions'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/rescuable.rb:22:in `process'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionview-5.1.6/lib/action_view/rendering.rb:30:in `process'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:609:in `block in process'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/notifications.rb:166:in `block in instrument'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/notifications.rb:166:in `instrument'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/base.rb:608:in `process'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/message_delivery.rb:105:in `block in processed_mailer'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/message_delivery.rb:104:in `tap'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/message_delivery.rb:104:in `processed_mailer'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/actionmailer-5.1.6/lib/action_mailer/message_delivery.rb:95:in `deliver_now'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/devise-4.5.0/lib/devise/models/authenticatable.rb:200:in `send_devise_notification'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/devise-4.5.0/lib/devise/models/confirmable.rb:121:in `send_confirmation_instructions'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/devise-4.5.0/lib/devise/models/confirmable.rb:183:in `send_on_create_confirmation_instructions'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:413:in `block in make_lambda'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:260:in `block in conditional'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:511:in `block in invoke_after'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:511:in `each'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:511:in `invoke_after'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:132:in `run_callbacks'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:827:in `_run_commit_callbacks'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/transactions.rb:343:in `committed!'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:86:in `commit_records'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:178:in `block in commit_transaction'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:168:in `commit_transaction'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:207:in `block in within_new_transaction'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/transactions.rb:210:in `transaction'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/transactions.rb:381:in `with_transaction_returning_status'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/transactions.rb:308:in `block in save'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/transactions.rb:323:in `rollback_active_record_state!'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/transactions.rb:307:in `save'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/suppressor.rb:42:in `save'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activerecord-5.1.6/lib/active_record/persistence.rb:34:in `create'
# ./spec/mailers/user_mailer_messages_spec.rb:91:in `block (2 levels) in <top (required)>'
# ./spec/mailers/user_mailer_messages_spec.rb:89:in `block in <top (required)>'
# ./spec/mailers/user_mailer_messages_spec.rb:3:in `<top (required)>'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
# /Users/melsatar/.rvm/gems/ruby-2.4.5/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'

最佳答案

似乎问题出在 Controller 的文件之一,我包括了引起冲突的贬值的 Rack::Test::Methods。如果您遇到类似问题,请在 rails 5.1 中将其删除

include Rack::Test::Methods

关于ruby-on-rails - NameError : undefined local variable or method `app' for - Rails 5. 1.6升级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53417425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com