草庐IT

java - 无法实例化类 : org. apache.naming.java.javaURLContextFactory

全部标签

ruby - Cucumber 测试无法启动,错误为 "Display socket is taken but lock file is missing.."

运行cucumber后bundleexeccucumberfeatures/emails.feature:20我遇到了错误Displaysocketistakenbutlockfileismissing-checktheHeadlesstroubleshootingguide(Headless::Exception)/Users/me/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/headless-2.2.0/lib/headless.rb:195:inensure_xvfb_is_running'/Users/me/.rbenv/ver

ruby - 使用名称访问实例变量(作为符号)

在Ruby中,我有这个类:classPositionattr_reader:x,:ydefinitialize(x,y)@x,@y=x,yendend我想要做的是使用符号访问x和y变量,如下所示:axis=:xpos=Position.new(5,6)#oneway:pos.axis#5(pos.x)#otherway:pos.get(axis)#5(pos.x)感谢thisquestion我发现使用这段代码,我可以实现第二种行为。#...classPositiondefget(var)instance_variable_get(("@#{var}").intern)endend但它看

ruby - ruby中类实例变量的垃圾回收

如果我使用类似的方法defself.get_service_clientreturn@service_clientif!@service_client.nil?@service_client=#initializelogicend现在@service_client是一个类的实例变量。它在内存中有多长时间?只要类在内存中(即像静态变量一样),我可以指望它不会被重新初始化吗? 最佳答案 类也是Ruby中的实例,但是当您以通常的方式定义类时,它会被分配给一个常量,并且该常量会被其他常量引用,从而阻止其被收集。因此,该类将无限期地存储在内存

ruby-on-rails - 已安装 gem 但无法加载此类文件

我做了以下事情geminstallcrack并添加了gem'crack'到我的gemfile。然后我需要require'crack'我尝试加载路线时遇到的错误是cannotloadsuchfile--crack我已经运行了gem环境并得到以下内容RubyGemsEnvironment:-RUBYGEMSVERSION:2.2.2-RUBYVERSION:2.1.0(2013-12-25patchlevel0)[x86_64-darwin12.0]-INSTALLATIONDIRECTORY:/Users/joshuahornby/.rvm/gems/ruby-2.1.0-RUBYEXE

ruby-on-rails - Ruby Gem (EventMachine) 无法使用 Bundler GEM 安装

所以我正在尝试安装GitLab,他们让我使用一个名为“bundler”的gem,它基本上安装了运行他们的应用程序所需的GEM。无论如何,在使用以下命令运行bundler之后:sudo-ugit-Hbundleinstall--deployment--withoutdevelopmenttestmysqlaws这将完美地安装大量gem,然后在安装后大约2分钟,我将在终端中收到以下错误。Ruby版本:来自SVN的最新版本(我已经检查过了,没问题)操作系统:Ubuntu14.04LTS(Trusty)Gem::Ext::BuildError:ERROR:Failedtobuildgemnat

ruby-on-rails - Rails 4 - 如何链接到 PDF 文件 (name.PDF)?

我正在生成PDF文件,我的链接如下所示::pdf%>当我点击它时,它会将我带到/display_invoice/123456789(这是一个HTML版本)。ControllerAction如下:defdisplay_invoiceifparams[:invoice_number]@invoice=...respond_todo|format|format.htmlformat.pdfdo#renderpdf:'123',#filenamerenderpdf:params[:invoice_number],layout:'layouts/application.pdf.erb'#,#la

ruby-on-rails - ArgumentError : Unknown key: :conditions. 有效键是 : :class_name, :class, :foreign_key

在尝试rake:dbmigrate之后,我在终端中得到了这个错误rakeaborted!ArgumentError:Unknownkey::conditions.Validkeysare::class_name,:class,:foreign_key,:validate,:autosave,:table_name,:before_add,:after_add,:before_remove,:after_remove,:extend,:primary_key,:dependent,:as,:through,:source,:source_type,:inverse_of,:counter

ruby - 单例类和实例变量

为什么instance_variables方法不显示针对变量a的@var_one?a=Object.newdefa.my_eval;yieldenda.my_eval{@var_one=1}a.instance_variables#=>[]instance_variables#=>[@var_one] 最佳答案 你应该使用instance_eval:a.instance_eval{@var_one=1}=>1a.instance_variables=>[:@var_one]当你使用普通的eval时,你在当前self的上下文中定义你的

ruby - 无法将 gemcutter 安装为 Ruby Gem 源

我正在尝试安装gemcutter.org上的thinkingsphinxgem当我运行命令时gemsources-ahttp://gemcutter.org我得到错误:Errorfetchinghttp://gemcutter.org:badresponseNotFound404(http://gemcutter.org/specs.4.8)如果我将上面的URL更改为http://gemcutter.org.specs.4.8.gz它找到一个文件。我如何告诉ruby​​gems使用.gz扩展名下载? 最佳答案 这看起来像是Gemcu

ruby-on-rails - respond_with 无法在 ruby​​ on rails 中工作。为什么?

我有一个名为join的post方法,它应该执行以下操作:1)创建一个新对象2)以json对象响应这是我的代码:classGameControllerparams[:name])@p.save!respond_with({:uuid=>@p.uuid})endend出于某种原因,respond_with调用总是失败并出现以下错误:undefinedmethod`model_name'forNilClass:Class如果我将respond_with调用更改为更简单的方法,我仍然会收到错误,例如:respond_with"hello"产生这个错误:undefinedmethod`hello