- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 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/
for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=a"') do (
我在 Javascript 中有一组全局计数器变量: var counter_0 = 0; var counter_1 = 0; var counter_2 = 0; 等等 然后我有一个 Javasc
好的,我正在阅读一些有关 RedBlackTrees 的代码。我注意到这一行“v1 = v2 = v3 = v4;”我理解类似“v1 += v2”(将 v2 添加到 v1 的当前值)和“v1 = v2
我正在为 C# 中的游戏数据加载制作一个 csv 阅读器,我想做的就是从数组(变量)的值声明一个变量,我们可以在 php 中像 $$foo 那样做。喜欢 void csvReader(string s
假设我有变量 内容为“ 123 ”和变量 b123 里面有一些文字。出于某种原因,我想使用变量 作为第二个 var 名称的一部分。像这样的东西: SET a=123 SET b123=some_tex
我对 javascript 有点陌生,我无法通过谷歌搜索找到任何内容,我正在编写一个程序,并且能够执行我所要求的操作: if (Variable == 1 或 Variable == 2 或 Vari
我发现我自己在做这种类型的 IF 语句分配。例如: if($variable == 1 || $variable == "whatever" || $variable == '492') { ...
我的虚拟 PC 在 MS-DOS 6.22 上运行时出现问题。 我需要使用变量 Date ,但我无法得到它,因为每当我尝试回显变量时,它都会显示 %variable%反而。 我在 Windows 控制
尝试运行此代码时: List list = em.createQuery("select balance b from Users where b.userName = '" + user_name.
我有一些代码,其中变量可以是 undefined、null 或正常值。无论变量是 undefined 还是 null,代码都需要做同样的事情。说有没有危险 for (var cur = this.bu
我正在编写一个批处理命令脚本,其中检查环境变量。我需要通过传递所有必需的变量来编写一个 FOR 循环,然后验证它是否已定义,如果未定义,则提示该键的值并永久设置该变量。 问题是我无法取消引用循环变量并
我知道这些是 Rails 的基础知识,但我仍然不知道 = 符号和 => 之间的全部区别以及 @some_variable 之间的区别、@@some_variable 和 :some_variable
我正在使用以下内容创建一个动态变量(PHP 术语中的“变量变量”): foo: "test1" set to-word (rejoin [foo "_result_data"]) array 5 但是
我一直在啃 PHP 套接字服务器和客户端的基础知识 here . 然后我偶然发现了这些行(摘自上面链接的第一个示例,发生在 while 中): if (false === ($buf = socket
这个问题在这里已经有了答案: What does "|=" mean? (pipe equal operator) (6 个答案) 关闭 9 年前。 我正在寻找一些编码来扩展我在 Java 方面的知
如何在 C++ 中从其他变量的值打印变量我只是 C++ 的新手。 在 php 中,我们可以通过其他变量的值来制作/打印一个变量。像这样。 $example = 'foo'; $foo = 'abc';
作为 Ruby on Rails 新手,我明白“@”和“:”引用有不同的含义。我看到了this post在 SO 中,其中描述了一些差异。 @ 表示实例变量(例如@my_selection) :表示别
编程新手/甚至更新。一个小的 go 程序有问题 - 不会编译带有 undefined variable 错误。代码: package main import ( "fmt" "io" "o
我知道其他一些语言,如PHP,支持“变量变量名”的概念--即,字符串的内容可以用作变量名的一部分。。我听说总的来说这不是一个好主意,但我认为它可以解决我在Python代码中遇到的一些问题。。有没有可能
我有两个版本的代码。 版本 1 Launcher.java class Launcher { public static void main(String[] args) {
我是一名优秀的程序员,十分优秀!