草庐IT

remove_not_if

全部标签

ruby-on-rails - 如何解决弃用警告 "Method to_hash is deprecated and will be removed in Rails 5.1"

我正在尝试更新到Rails5,我收到以下弃用警告:DEPRECATIONWARNING:Methodto_hashisdeprecatedandwillberemovedinRails5.1,asActionController::Parametersnolongerinheritsfromhash.Usingthisdeprecatedbehaviorexposespotentialsecurityproblems.Ifyoucontinuetousethismethodyoumaybecreatingasecurityvulnerabilityinyourappthatcanbee

ruby-on-rails - rake 数据库 :reset 'user does not have CONNECT privilege'

所以我在我的Rails应用程序中使用HerokuPostgres,但我没有在Heroku本身上托管我的应用程序。我在我的database.yml中使用了来自Heroku的ActiveRecord连接详细信息,它看起来像这样:development:adapter:postgresqlencoding:unicodepool:5database:[database]username:[username]password:[password]host:ec2-54-227-243-78.compute-1.amazonaws.comport:5432但是,现在我正在尝试rakedb:mig

ruby - Windows 上的 Jekyll : Pygments not working

在我一直使用RC之前,我已经更新到最新的JekyllBuild(1.0.3)。更新代码解析后(使用Pygments)不再起作用。我总是收到以下错误:C:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162:warning:cannotclosefdbeforespawn←[31mLiquidException:Nosuchfileordirectory-/bin/shin2012-01-17-test-post.md←[0m有没有人也遇到过这个问题?我对ruby一无所知,所以我不能自己调试:

ruby-on-rails - gem 更新后 : test fail with "Asset was not declared to be precompiled in production"

由于我更新了几个gem,所以所有测试都失败并出现错误:ActionView::Template::Error:Assetwasnotdeclaredtobeprecompiledinproduction.AddRails.application.config.assets.precompile+=%w(favicons/manifest.json.erb)toconfig/initializers/assets.rbandrestartyourserverapp/views/layouts/_faviconsheader.html.erb:14:in_app_views_layouts

ruby - 我可以使用 `else if` 而不是 `elsif` 吗?

在elsif上使用elseif是否安全?使用elsif是否更好,因为它遵循Ruby的类型惯例?或者这是一种偏好?这是摘自一本书的一段代码。我添加了额外的end关键字并将elsif关键字替换为elseif。defdescribe(inhabitant)ifinhabitant=="sophie"puts'gender:female'puts'height:145'elseifinhabitant=="paul"puts'gender:male'puts'height:145'elseifinhabitant=="dawn"puts'gender:female'puts'height:17

ruby - Ruby 中的方法 : objects or not?

灵感来自thisdiscussion,经过一些谷歌搜索后,我无法找到关于Ruby中方法的一个非常简单的问题的答案:方法是否是对象?众说纷纭here和there,而且我真的很想听听深入的解释。我知道Object#method方法,它接受一个方法名称并返回一个Method实例,但是,另一方面,你也有类似的事情可以使用block将它们变成Proc实例,而block不是对象,那么是什么让方法有什么不同呢? 最佳答案 MethodsareafundamentalpartofRuby'ssyntax,buttheyarenotvaluestha

ruby - 如何在 Ruby 中编写复杂的多行 if 条件?

如何在Ruby中编写这个多行的复杂条件if语句?if((aa!=nil&&self.prop1==aa.decrypt)||(bb!=nil&&self.prop2==bb.decrypt))&&(self.id.nil?||self.id!=id)returntrueend我遇到语法错误;意外的tOROP。用Java,我可以写if(((aa!=null&&aa.prop1.equals(aa.decrypt()))||(bb!=null&&bb.prop2.equals(bb.decrypt())))&&(this.id!=id)){returntrue;}

ruby - puppet/角色 "Could not retrieve fact fqdn": How to fix or circumvent?

我正在学习puppet并尝试在家里的VM上进行试验。我还没有使用puppet服务器,只是在本地运行。它工作正常,但每次我运行puppetapply...时,我都会延迟几秒钟,然后显示消息warning:Couldnotretrievefactfqdn我假设消息与延迟有关,我想摆脱它(延迟——我可以接受消息)。谷歌搜索解决方案似乎表明它在某种程度上与DNS查找有关,但我真的找不到其他任何关于它的信息,这似乎令人惊讶。我想要的只是能够在我的虚拟机中快速应用list,以便我可以进行试验。我怎样才能加快速度?更新:我在调试输出中没有看到任何额外信息,但它看起来像这样:$puppetapply-

ruby - `if __FILE__ == $0` 在 Ruby 中是什么意思

if__FILE__==$0$:.unshiftFile.join(File.dirname(__FILE__),'..')我在Ruby中找到这段代码,什么意思? 最佳答案 #Onlyrunthefollowingcodewhenthisfileisthemainfilebeingrun#insteadofhavingbeenrequiredorloadedbyanotherfileif__FILE__==$0#Findtheparentdirectoryofthisfileandaddittothefront#ofthelisto

ruby-on-rails - 带 ruby​​ 调试器的 Rails 抛出 'Symbol not found: _ruby_current_thread (LoadError)'

我有标准的ruby​​-head和Rails3.1rc4。我按照http://dirk.net/2010/04/17/ruby-debug-with-ruby-19x-and-rails-3-on-rvm/中的说明安装了ruby​​-debug。但是当我运行railss--debugger时它会抛出这个奇怪的错误/Users/schovi/.rvm/gems/ruby-head/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in`require':dlopen(/Users/schovi/.rvm