草庐IT

how-to-change-the-android-emulato

全部标签

ruby-on-rails - Thinking sphinx - 带条件连接的索引 (has_and_belongs_to_many)

我有模型Service,它具有按服务类型ID过滤服务的范围:classServiceids{joins(:service_types).where('service_types_services.service_type_idin(?)',ids)}endclassServiceType所以,当我运行scope时,我得到这样的结果:Service.by_service_types([54])ServiceLoad(0.8ms)SELECT"services".*FROM"services"INNERJOIN"service_types_services"ON"service_types

ruby 雾 gem : how to create sub-directories?

我有connection=Fog::Storage.new(fog_config)bucket=connection.directories.get(bucket_name)有没有办法(已记录、未记录、变通)让我在此存储桶内创建目录?像这样的东西:sub_dir_for_user_1=bucket.create_sub_dir('/user_1_files')sub_dir_for_user_2=bucket.create_sub_dir('/user_2_files') 最佳答案 在S3中,带有尾部斜杠的零字节文件将创建一个伪目录

ruby-on-rails - rspec rails 测试 : how can I force ActiveJob job's to run inline for certain tests?

我希望我的后台作业能够内联运行某些标记测试。我可以通过用perform_enqueueddo包装测试来做到这一点,但我希望能够用元数据标记它们,如果可能的话,它会自动发生。我试过以下方法:it"doeseverythinginthejobtoo",perform_enqueued:truedoendconfig.around(:each)do|example|ifexample.metadata[:perform_enqueued]perform_enqueued_jobsdoexample.runendendend但它会导致错误:undefinedmethod`perform_enq

c - Ruby c 扩展 : How can I catch all exceptions, 包括不是 StandardErrors 的东西?

在ruby中,begin#...rescue#...end不会捕获不是StandardError子类的异常。在C中,rb_rescue(x,Qnil,y,Qnil);VALUEx(void){/*...*/returnQnil;}VALUEy(void){/*...*/returnQnil;}会做同样的事情。我如何从ruby​​C扩展中rescueException=>e(而不仅仅是rescue=>e)? 最佳答案 Ruby需要更多文档。我不得不进入ruby​​源代码,这是我发现的:VALUErb_rescue(VALUE(*b_p

ruby-on-rails - Ruby on Rails 教程 - 5.26 - Sublime Text "Unable to Save"新文件 "spec/support/utilities.rb"

我正在使用SublimeText2,同时遵循MichaelHartl的RubyonRails教程。可以在http://ruby.railstutorial.org/book/ruby-on-rails-tutorial找到我所指的教程的具体部分。(ctrl+F“list5.26”)。我能够创建规范/支持文件。但是,在尝试创建spec/support/utilities.rb文件时,我收到消息“无法保存~/rails_projects/sample_app/spec/support/utilities.rb”。有人知道为什么会这样吗?SublimeText论坛上有人似乎遇到了完全相同的问

ruby - 在 ruby​​ Selenium 中移动鼠标(move_to)

我正在尝试使用Ruby中的SeleniumWebDriver2.4模拟鼠标移动如果我运行测试,是否应该看到鼠标在我的屏幕上移动?我很困惑。我试过很多不同的方法示例代码:require'selenium-webdriver'driver=Selenium::WebDriver.for:firefoxdriver.navigate.to'http://www.google.com'element=driver.find_element(:id,'gbqfba')那我试过了driver.action.move_to(element).performdriver.mouse.move_to(e

ruby 在 `gem_original_require' : no such file to load -- CloudyScripts (LoadError)

在Ubuntu和Ruby1.8.7上,我通过以下方式安装了CloudyScripts:geminstallgeminstallCloudyScripts当我尝试执行此操作时:require'rubygems'require'CloudyScripts'我收到以下错误:/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in`gem_original_require':nosuchfiletoload--CloudyScripts(LoadError)from/usr/lib/ruby/1.8/rubygems/custom_require.r

ruby-on-rails - rails 3/ActiveRecord : How to switch/change table name during request dynamically?

我想在请求期间动态更改ActiveRecord模型类的表名。例如,有许多具有相似结构(列)的表:mydb:sample_data_12222sample_data_12223sample_data_12224sample_data_12225...所以,我想做的是..._1。定义基本模型类,如:classSampleData_2。在请求期间更改目标表,例如:defaction_methodSampleData.set_table_name"sample_data_#{params[:id]}"@rows=SampleData.all如果在非线程环境(如Passenger/mod_rai

ruby-on-rails - ruby rails : Best way to test a failed call to a third party API

我现在调用第三方网络服务作为我的应用程序的一部分。我正在使用RestClientgem来执行此操作。有大量工具可以用来做同样的事情,所以这应该无关紧要。我很好奇的是有足够好的测试,没有什么太花哨的,我可以在其中模拟当第三方Web服务出于任何原因不可用时我的应用程序如何响应。无论是我超出了速率限制还是由于网络延迟/并发症而超时,我只想能够获取HTTP状态代码之类的东西并测试我的应用程序在该事件中执行的操作。使用Test::Unit执行此操作的最佳方法是什么?现在,对第三方服务的调用封装在我的一个Controller中。我有一个简单的模块,其中包含一些用于远程服务不同端点的包装器方法。我只

ruby-on-rails - Jobs with Resque gives "Don' t know how to build task 'jobs:work' "on Heroku

我遵循了https://devcenter.heroku.com/articles/queuing-ruby-resque上的教程在Rails应用程序中排队和运行后台作业。在对作业进行排队后,它似乎没有运行任何作业,因为在控制台中我可以看到作业尚未处理>Resque.info=>{:pending=>1,:processed=>0,:queues=>1,:workers=>0,:working=>0,:failed=>0,:servers=>["redis://dory.redistogo.com:9826/0"],:environment=>"production"}如果我尝试(本地