草庐IT

start_of_season

全部标签

ruby-on-rails - Capistrano gzip : stdin: unexpected end of file interruption

我在Capistrano部署方面遇到问题。部署过程因Gzip错误而被丢弃。它可以是什么?capflowdeploy*executing`flow'*executing`deploy'*executing`deploy:update'**transaction:start*executing`deploy:update_code'*getting(viacheckout)revisionto/tmp/20111214204507executinglocally:cp-R./tmp/20111214204507commandfinishedin413mscompressing/tmp/20

ruby-on-rails - rails : Prevent will_paginate from calling #count of ActiveRelation

当我向will_paginate传递一个ActiveRelation时,它总是调用它的#count方法并访问数据库以找出项目的总数。但是这个操作需要时间,而且我已经缓存并准备好了总数。我可以将这个预先计算的计数传递给will_paginate并阻止它访问数据库吗?我尝试了:count选项,但它作为选项传递给了ActiveRecord:active_relation.paginate(page:2,per_page:100,count:total_count)谢谢!:) 最佳答案 通过:total_entries传递缓存计数解决了问题

ruby-on-rails - 带分号的字符串在 RubyMine 中产生 "unterminated string meets end of file"

在RubyMine调试器中,只需在watch中输入:';'或";"我收到错误:"unterminatedstringmeetsendoffile"这是为什么?据我所知,它不会发生在Rails控制台中,并且与RubyMine没有任何关系。 最佳答案 这是Ruby调试器与Ruby解释器具有不同解析规则的结果。事实上,从irb或ruby命令调用的常规Ruby调试器表现出相同的行为。然而,解决方法很简单:要创建一个由单个分号组成的字符串文字,只需使用反斜杠将其转义即可:$irb>require'debugger'=>true>debugge

ruby - 轨道 4 log4r server.rb :78:in `start' : undefined method `formatter'

我已经研究这个话题太久了,所以我必须发布这个。我有几个运行此设置的应用程序,其中一个在rails启动(railss)时完全失败。它们的配置几乎完全相同,但我似乎无法在这里大海捞针。有没有人对如何找到这个问题有任何指示?设置基于:http://blog.mmlac.com/log4r-for-rails/comment-page-1/#comment-1731当我尝试运行railss时:=>BootingWEBrick=>Rails4.0.0applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Run`railsserver-h`f

Ruby 设置类 : equality of sets

根据RubySet类的文档,“==如果两个集合相等,则返回true。每对元素的相等性根据Object#eql?定义。可以使用Date对象来演示其本质,其中包含不同Date对象但具有相同日期的集合比较相等:require'set'd1=Date.today#=>Thu,30Sep2010putsd1.object_id#=>2211539680d2=Date.today+1#=>Fri,01Oct2010putsd2.object_id#=>2211522320set1=Set.new([d1,d2])d11=Date.today#=>Thu,30Sep2010putsd11.objec

ruby-on-rails - 'starts_with' 和 'start_with' 在 Ruby 中有相同的功能吗?

显然他们在任何输入上都给我相同的输出,比如"Rubyisred".start_with?("Ruby")或"Rubyisred".starts_with?("Ruby")两者都给出相同的结果。 最佳答案 在Ruby添加String#start_with?作为核心库的一部分之前,Rails的主动支持实现了String#starts_with?方法。现在它只是为了向后兼容而保留的别名。是的-他们做同样的事情,第一个来自Ruby,第二个-来自Rails。 关于ruby-on-rails-'st

ruby-on-rails - validates_associated 和 validates_presence_of 没有按预期与 rspec 一起工作?

我有一个用户模型和一个友谊模型。classFriendship'User',:foreign_key=>'sender_id'belongs_to:receiver,:class_name=>'User',:foreign_key=>'receiver_id'validates_presence_of:receiver_id,:sender_idvalidates_associated:receiver,:senderendclassUser"Friendship",:foreign_key=>"sender_id",:dependent=>:destroyhas_many:recei

ruby-on-rails - 迪尔德 : Symbol not found: _rb_ary_new_from_values When trying to run foreman start

尝试运行“foremanstart”来执行我的rails文件时,我收到以下错误。dyld:Symbolnotfound:_rb_ary_new_from_valuesReferencedfrom:/Users/paulbattisson/.rvm/gems/ruby-2.1.1/gems/psych-2.0.5/lib/psych.bundleExpectedin:flatnamespace如果我运行railss那么应用程序可以正常启动,但是我想使用以下Procfile:web:bundleexecrackupconfig.ru-p$PORTresque:envTERM_CHILD=1

ruby - 使用 Ruby 和 net-ssh,如何通过 Net::SSH.start 使用 key_data 参数进行身份验证?

我已经阅读了net-ssh文档,但我仍然感到困惑。我可以手动进行身份验证(使用ssh-i...),也可以将key放在文件中并使用:keys参数。但是,我不想使用:keys参数,我想使用:key_data参数。任何人都可以举一个工作的例子吗?出于某种原因,直接将字符串输入:key_data是行不通的,它给出了错误:“既不是PUBkey也不是PRIVkey::嵌套的asn1错误”。当然,我用谷歌搜索了一下,它基本上告诉我要确保key是PEM格式。而且,当然是。有任何想法吗?如果需要,我可以提供更详细的信息... 最佳答案 我看到这个问题

ruby - 应该 validate_format_of 。 not_with 在框架中有问题(或者在我的理解中)

我将以下代码放入RSpec测试中:it{shouldvalidate_format_of(:email).not_with('test@test')}并设置实际的类:validates:email,:presence=>true,:format=>/\b[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b/i当我运行测试时,我得到:失败:1)用户失败/错误:它{应该validate_format_of(:email).not_with('test@test')}当电子邮件设置为“test@test”时,预期错误包括“can'tbeblank”,得到错误