草庐IT

android - 无法在模拟器中启动 avd

全部标签

ruby-on-rails - 启动 Rails 服务器时出错 - 获取 "uninitialized constant Devise::Models::Invitable (NameError)"

我是Rails的新手,正在尝试按照这个预启动注册教程进行操作-http://railsapps.github.com/tutorial-rails-prelaunch-signup.html使用$railss初始化rails服务器时,我收到以下错误消息:Users/pv/.rvm/gems/ruby-1.9.3-p194@rails326/gems/devise-2.1.2/lib/devise/models.rb:97:in`const_get':未初始化常量设计::模型::邀请(NameError)后面跟着一堆文件路径,比如:from/Users/patrickvihtelic/.

ruby-on-rails - Foreman无法启动Nginx,但我可以手动启动。为什么?

我目前正在运行Foreman在暂存(Ubuntu)上,一旦我开始工作,就会切换到使用upstart。我的Procfile.staging看起来像这样:nginx:sudoservicenginxstartunicorn:bundleexecunicorn-c./config/unicorn.rbredis:bundleexecredis-serversidekiq:bundleexecsidekiq-v-C./config/sidekiq.yml我可以使用以下方法成功启动nginx:$sudoservicenginxstart然而,当我运行$foremanstart时,当其他三个进程成

sql - 如何模拟ActiveRecord Model.count.to_sql

我想显示一个计数中使用的SQL。但是,Model.count.to_sql将不起作用,因为count返回一个没有to_sql方法的FixNum。我认为最简单的解决方案是这样做:Model.where(nil).to_sql.sub(/SELECT.*FROM/,"SELECTCOUNT(*)FROM")这会创建与Model.count中使用的SQL相同的SQL,但它是否会导致进一步的问题?例如,如果我添加一个复杂的where子句和一些连接。有更好的方法吗? 最佳答案 你可以试试Model.select("count(*)asmode

ruby-on-rails - `allow_any_instance_of` 模拟不在范围内工作

我的mock只有在如下所示的beforeblock中时才有效。这只是我对我的问题的快速而肮脏的表述。从字面上看,当我将行从beforeblock移动到doesnotquack断言时,它停止模拟:(describe'Ducks',type::featuredobeforedo...allow_any_instance_of(Duck).toreceive(:quack).and_return('bark!')visitanimal_farm_pathendcontext'isanoddduck'it'doesnotquack'doexpect(Duck.new.quack).toeq('

ruby - 无法使用 gem 添加源

我正在尝试添加http://rubygems.org/在我的源代码中,因为我无法使用“geminstallNAME”(此错误:无法在任何存储库中找到有效的gem“dashing”(>=0))。所以,我执行了这个命令:gemsources-ahttp://rubygems.org/结果:错误:执行gem时...(Gem::OperationNotSupportedError)未连接到tty且未指定默认值我给你我的环境:$gemenvRubyGemsEnvironment:-RUBYGEMSVERSION:2.4.5.1-RUBYVERSION:2.2.4(2015-12-16patchl

ruby - 启动和停止 Ruby 线程

我如何从另一个线程中启动和停止一个单独的线程?loop_a_stopped=trueloop_a=Thread.newdoloopdoThread.stopifloop_a_stopped#Dostuffsleep3endendloop_b=Thread.newdoloopdoresponse=ask(">")caseresponse.strip.downcasewhen"start"loop_a_stopped=falseloop_a.runwhen"stop"loop_a_stopped=truewhen"exit"breakendendendloop_a.joinloop_b.j

ruby - 无法从 Jekyll 插件获取页面数据

我正在尝试为Jekyll编写一个自定义标签插件,它将输出站点上所有页面(不是帖子)的分层导航树。我基本上想要一堆嵌套的链接(以页面标题作为链接文本)指向具有特定CSS类标记的当前页面的页面。我对ruby​​非常缺乏经验。我是PHP专家。我想我应该从尝试遍历所有页面并输出一个一维列表开始,只是为了确保我至少可以做到这一点。这是我到目前为止所拥有的:moduleJekyllclassNavTree'site.pages.eachdo|page|output+=''+page.title+''endoutput+=''outputendendendLiquid::Template.regis

ruby-on-rails - 使用 Rspec 测试和模拟服务

我创建了一个名为Transaction的服务对象,它处理下达的订单、设置付款,然后设置模型关联。这个类叫做Transaction,有两个方法,initialize和pay。我正在spec/services/中测试它(它在app/services中)。initialize方法接受一个account和用户传入的一些参数来处理订单。我正在尝试使用rspec测试pay。我实际上如何进行这样的测试?这个功能有很多事情要做。例如,它创建新模型,然后在它们之间建立一些关联。到目前为止,我创建了一个双重帐户,如下所示:@account=double("account",:confirmed=>true

ruby-on-rails - 无法安装 gems,因为 "undefined method ` invoke_with_build_args' for nil :NilClass"

我在Rubyrails上,我正在安装RubyonRails。我正在尝试安装gems,但它没有发生,我不确定为什么以及如何修复它。$geminstallbundlerERROR:Loadingcommand:install(LoadError)dlopen(/Users/nthulanemakgato/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle,9):Librarynotloaded:/usr/local/opt/openssl/lib/libssl.1.0.0.dylibReferenced

ruby-on-rails - 无法使用 Stripe 保存或取消订阅

将stripe的API与RubyonRails结合使用我无法保存订阅。我能够检索、更新和保存客户对象:customer=Stripe::Customer.retrieve(some_customer_id)#thisworkscustomer.save#thisworks我还可以检索订阅:subscription=customer.subscriptions.retrieve("some_subscription_id")#这个有效但是,在尝试保存订阅时:subscription.save#这不起作用我不断得到这个:NoMethodError:undefinedmethod`save'