Tag: ruby

试图为ror app设置postgres,收到错误 – fe_sendauth:没有提供密码

获得: An error has occurred: Error connecting to the server: fe_sendauth: no password supplied database.yml中的设置与其他计算机上的应用程序设置相同。 如何设置以便我不需要硬编码的密码? 我可以使用PgAdmin-III查看db ok。 我宁愿没有database.yml的密码,因为使用这个应用程序的其他机器没有/需要它,所以它似乎可能与我的Pg安装有关。

使用Xcode 4.3.1在Mac上更新Ruby

我正在使用RVM来安装它,它给了我这个错误: The provided compiler ‘/usr/bin/gcc’ is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`. 我在Lion 10.7.3上,我有Xcode 4.3.1。

Paperclip在保存后重命名文件

如何在上传和保存文件后重命名文件? 我的问题是我需要自动解析有关文件的信息,以便提出文件应该像我的应用程序一样保存文件名,但我无法访问生成文件名所需的信息,直到记录为止。模型已保存。

如何将字符串转换为方法调用?

如何使用字符串作为方法调用? “Some Word”.class #=> String a = “class” “Some World”.a #=> undefined method ‘a’ “Some World”.”#{a}” #=> syntax error, unexpected tSTRING_BEG

当我运行`bundle exec rake test:prepare`它出错了,但是`bundle exec rake db:test:prepare`会很好地发出警告。 这是怎么回事?

所以根据这个链接,一个是快捷包装器(所以我猜它们是相同的)。 当我运行bundle exec rake db:test:prepare ,我收到此错误: Don’t know how to build task ‘test:prepare’ /Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval’ /Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `’ …但是当我运行bundle exec rake db:test:prepare ,我收到此警告: WARNING: db:test:prepare is deprecated. The Rails test helper now maintains your test schema automatically, see the release notes for details. 任何人都可以阐明这一点吗?

找不到捆绑命令。 坏翻译

我对bundler gem有一些问题。 当我运行“gem list”时,我可以看到已经安装了bundler。 “bundler(1.1.3,1.0.21)”。 但是,当我尝试运行命令“bundle”时,我收到以下消息: sh.exe”: /c/Program Files (x86)/ruby-1.9.3/bin/bundle: “c:/Program: bad interpreter: No such file or directory 我认为这是一些路径错误,但无论我谷歌多少,我都无法找到解决问题的方法。 有人有任何提示吗? 这是我的路径: C:\Program Files (x86)\AMD APP\bin\x86_64; C:\Program Files (x86)\AMD APP\bin\x86; C:\Program Files\Common Files\Microsoft Shared\Windows Live; C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live; C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common; %SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static; C:\Windows\system32\gs\gs8.71\bin; C:\Program Files […]

如何确保Ruby使用不易受Heartbleed攻击的OpenSSL?

关于Heartbleed错误, ruby-lang.org上的这篇文章描述了如何检查漏洞和升级。 它包括这个建议: 要validation链接到Ruby的OpenSSL库的哪个版本,请使用以下命令: ruby -v -ropenssl -rfiddle -e ‘puts Fiddle::Function.new(Fiddle.dlopen(nil)[“SSLeay_version”], [Fiddle::TYPE_INT], Fiddle::TYPE_VOIDP).call(0)’ 要validation当前使用Ruby安装的OpenSSL的版本,请使用以下命令: ruby -ropenssl -e ‘puts OpenSSL::OPENSSL_VERSION’ 这两个检查有什么区别,如果从任一命令返回错误版本,建议采取什么操作?

如何修复Rubygems最近的弃用警告?

我最近运行更新: gem update –system gem update 现在,每次加载gem时,我都会收到很多弃用警告。 例如, rails console : NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::Specification#default_executable= called from /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10. NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::Specification#default_executable= called from /Users/user/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec:10. NOTE: Gem::Specification#default_executable= is deprecated with no […]

为什么我可以引用从未运行的if / unless / case语句之外的变量?

为什么以下代码不会抛出错误? if false x = 0 end x #=> nil 以下确实会引发错误: y # NameError: undefined local variable or method `x’ for main:Object unless & case语句也会发生同样的事情。

什么时候Ruby中的’eval`是合理的?

“ ‘eval’应该是令人讨厌的吗? ”这启发了这个: 大多数人都同意eval是坏的,并且在大多数情况下更优雅/更安全。 所以我想问一下:如果经常误用eval ,它真的需要作为语言function吗? 这是邪恶而不是好吗? 就个人而言,我发现它唯一有用的地方是插入配置文件中提供的字符串。 编辑:这个问题的目的是在eval是唯一或最佳解决方案时尽可能多地获得真实案例。 所以,请不要进入“应该用语言限制程序员的创造力”的方向。 Edit2:当我说eval时,我当然是指eval ing字符串,而不是将ruby块传递给instance_eval或class_eval 。