草庐IT

undefined-reference

全部标签

ruby-on-rails - `undefined method ` 查找 Assets ' for nil:NilClass`

我正在使用'rails'、'4.2.5'和wicked_pdfgem来生成和下载PDF,但是在Heroku上,它不包括使用的csswicked_pdf_stylesheet_link_tag标签。Heroku错误日志:ActionView::Template::Error(undefinedmethod'find_asset'fornil:NilClass)我是否遗漏了这里的任何配置? 最佳答案 要使其适用于开发和生产环境,请不要使用Rails.application.assets.find_asset(logical_file_p

ruby - irb 中的所有命令都给出 "NoMethodError: undefined method ` write' for nil :NilClass"

我正在尝试从IRB获取当前的ruby​​版本,但它给我这个错误:>>RUBY_VERSIONNoMethodError:undefinedmethod`write'fornil:NilClassfrom/usr/local/lib/ruby/1.9.1/irb.rb:311:in`printf'from/usr/local/lib/ruby/1.9.1/irb.rb:311:in`output_value'from/usr/local/lib/ruby/1.9.1/irb.rb:160:in`block(2levels)ineval_input'from/usr/local/lib/r

Ruby 2.4.1 Dir.children( dirname ) 为 Dir :Class"返回 "undefined method ` children'

我是Ruby的新手,正在尝试学习它。我使用的是最新的Ruby版本(2.4.1)和交互式RubyShell。我在Dir类中遇到过children方法。我试过这个例子fromthedocumentation:Dir.children("testdir")#=>["config.h","main.rb"]但它似乎不起作用,因为我收到以下消息:undefinedmethod`children'forDir:Class我错过了什么? 最佳答案 这似乎是某种文档困惑。Dir.children方法是在Feature#11302中引入的进入Ruby

ruby - undefined symbol : SSLv3_method - . ../openssl.so 与 Ruby 和 ArchLinux

ArchLinux最近的OpenSSL更新破坏了Ruby,因为后者依赖于前者支持的SSLv3。使用OpenSSL的Ruby代码会在它们终止并出现如下错误时揭示问题:openssl.so:undefinedsymbol:SSLv3_method-.../openssl.so(LoadError)我将多个版本的Ruby与RVM一起使用这个问题适用于所有人。我遇到问题的OpenSSL版本是1.0.2h,但我相信它是在1.0.2g中引入的。版本1.0.2f工作正常。如何解决兼容性问题(不降级OpenSSL)? 最佳答案 问题是由于ArchL

ruby - 在 Ruby 中,对于 undefined variable "foo",为什么 "foo = foo"不引发错误?

当foo是一个undefinedvariable时,试图访问它会引发一个NameError:foo#=>NameError:undefinedlocalvariableormethod`foo'a=foo#=>NameError:undefinedlocalvariableormethod`foo'为什么foo=foo不引发NameError?foo=foo#=>nil昨天,我花了几个小时才将这一行作为程序中的错误来追踪......capture=capture.to_i我本来打算做的是将capture_str转换为Integer。我所做的是通过说capture=capture来引入n

ruby-on-rails - Rails 4 + Rspec + 设计 : undefined method 'env' in controller specs for sign_in a user

在我的spec_helper.rb中我添加了config.includeDevise::TestHelpers,:type=>:controller在:allhook之前的Controller规范中,我正在尝试使用此代码登录用户@request.env["devise.mapping"]=Devise.mappings[:user]user=FactoryGirl.create(:confirmed_user)sign_inuser并得到NoMethodError:undefinedmethod`env'fornil:NilClass。有什么想法吗? 最佳答

ruby-on-rails - database.yml &references 不工作

我们刚刚将虚拟机升级到我认为相同的ruby​​配置(通过RVM...Ruby1.9.2、Rails3.0.7、DataMapper1.1.0)。最大的区别是我们从MySQL5.0升级到5.1。出于某种原因,在我们的旧VM上运行的完全相同的代码/database.yml现在在我们的新VM尝试连接到数据库时失败了。问题是这个YAML:mysql_defaults:&mysql_defaultsadapter:mysqlencoding:UTF-8username:userpassword:passhost:localhostdevelopment:正在扩展到:"mysql_defaults

Ruby 哈希错误 : undefined method [] when attempting to set deeply nested keys

我有一段代码是这样的:my_hash={}first_key=1second_key=2third_key=3my_hash[first_key][second_key][third_key]=100ruby解释器给了我一个错误:undefinedmethod`[]'fornil:NilClass(NoMethodError)那么这是否意味着我不能那样使用哈希?还是您认为此错误可能是其他原因造成的? 最佳答案 哈希默认不嵌套。由于my_hash[first_key]未设置任何值,因此它是nil。并且nil不是散列,因此尝试访问其中一

ruby - 为什么 'undefined method ` assert_equal' ' is thrown even after requiring ' test/unit'

我打开irb并输入:require'test/unit'但是当我使用assert_equal方法时,出现以下错误:NoMethodError:undefinedmethod'assert_equal'formain:Object。为什么即使在需要“测试/单元”之后也会发生这种情况? 最佳答案 assert_equal是在Test::Unit::TestCase的子类上定义的,因此仅在该类中可用。您可能会成功地使用includeTest::Unit::TestCase将这些方法加载到当前范围。更有可能的是,您最好将测试写在一个短文件中

ruby 新手 : undefined method `with_indifferent_access'

我是一名新的Ruby程序员,我的一位同事帮助我开始编写了以下代码,该代码在他的环境中运行良好。但是,当我尝试在自己的环境中运行它时,出现以下错误:undefinedmethod'with_indifferent_access'for#(没有方法错误)有问题的方法在代码中出现了两次:require'rubygems'gem'activerecord'gem'activesupport'gem'sailthru-client'require'active_support'require'active_record'require'sailthru'#SetupourSailthruobje