草庐IT

PORT_NUMBER

全部标签

ruby-on-rails - 为什么 foreman gem 会忽略 PORT 环境变量?

我希望工头gem使用我的开发环境文件中提供的PORT值,而不是使用它自己的值。我的文件设置如下所示:启动工头的bash脚本:foremanstart-edevelopment.envdevelopment.env文件内容:端口=3000Procfile内容web:bundleexecrailsserverthin-p$PORT-e$RAILS_ENV$1开发服务器最终在端口5000上启动。我知道我可以用--p3000启动工头以强制它使用该端口。但这违背了env文件的目的。有什么建议吗? 最佳答案 我知道这是一篇旧帖子,但我花了一段时

ruby-on-rails - minitest_plugin.rb :9 getting wrong number of arguments

~/Sites/sample_app$railstestRunningviaSpringpreloaderinprocess24338Runoptions:--seed58780Running:..Finishedin0.292172s,6.8453runs/s,6.8453assertions/s./var/lib/gems/2.3.0/gems/railties-5.1.0/lib/rails/test_unit/minitest_plugin.rb:9:in`aggregated_results':wrongnumberofarguments(given1,expected0)(

ruby - 如何解决 factory_girl wrong number of arguments 错误

#rspectestcode@room=FactoryGirl.build(:room)#factorydefinitionfactory:roomdolength{10}width{20}end#codeimplementationclassRoomattr_accessor:length,:widthdefinitialize(length,width)@length=length@width=widthendend在尝试构建@room时运行rspec会导致此错误ArgumentError:wrongnumberofarguments(0for2) 最佳

ruby-on-rails - 在 rails3 的 Controller 上使用 number_with_precision

我想在Controller上使用这个辅助方法。有什么办法可以实现吗? 最佳答案 可能不是一个好主意,但如果必须,请像这样包含帮助程序:classWhateverControllerincludeActionView::Helpers::NumberHelperdefshowrender:text=>number_with_precision(2342.234,:precision=>2)endend 关于ruby-on-rails-在rails3的Controller上使用number_

ruby - Rspec 模拟错误 : wrong number of arguments

我正在尝试使用Rspec对StripeAPI进行stub,但我遇到了一个问题。这是我的代码的样子:Stripe::Customer.should_receive(:create).with(any_args).and_raise(Stripe::CardError)这是我遇到的错误:Failure/Error:Stripe::Customer.should_receive(:create).with(any_args).and_raise(Stripe::CardError)ArgumentError:wrongnumberofarguments(0for3..6)

ruby - 尝试从 FTP 下载文件导致 "500 Illegal PORT command"错误

如果我在本地执行,一切正常:require'net/ftp'ftp=Net::FTP.new("myftpserver.com","username","password")ftp.getbinaryfile("/myfile.zip","localfile.zip")ftp.close如果我尝试在我使用的Linux服务器上执行它,结果是:/usr/local/lib/ruby/1.9.1/net/ftp.rb:273:in`getresp':500IllegalPORTcommand.(Net::FTPPermError)from/usr/local/lib/ruby/1.9.1/n

ruby-on-rails - rails : remove decimal from number_to_currency

我有一个float价格:number_to_currency(m.price,:locale=>'en_us')我得到:$39.00如何删除.00,我想得到:$39 最佳答案 您可以按照记录将精度设置为0here在RailsAPI文档中。number_to_currency(m.price,locale::en,precision:0)请注意,您的价格将进行四舍五入,从38.50美元到39.49美元的任何价格都将显示为39美元。编辑:将区域设置:en_us替换为:en,这可能会在更多应用中启用。

ruby - "wrong number of arguments (1 for 0)"在 Ruby 中是什么意思?

“参数错误:参数数量错误(1代表0)”是什么意思? 最佳答案 当您定义一个函数时,您还定义了该函数需要工作的信息(参数)。如果它被设计为在没有任何额外信息的情况下工作,并且你传递了一些信息,你就会得到那个错误。例子:不接受参数:defdogend接受参数:defcat(name)end当你调用它们时,你需要用你定义的参数来调用它们。dog#worksfinecat("Fluffy")#worksfinedog("Fido")#ReturnsArgumentError(1for0)cat#ReturnsArgumentError(0f

ruby-on-rails - ruby rails : How do you add add zeros in front of a number if it's under 10?

我想像这样将一位数转换为两位数:9==>095==>0512==124==>04我认为我可以放置一堆if-else语句(如果数字小于10,则执行gsub)但我认为那是可怕的编码。我知道Rails有number_with_precision但我发现它只适用于十进制数。关于如何将个位数转换为两位数有什么想法吗? 最佳答案 很多人使用sprintf(这是正确的做法),我认为如果你想对字符串执行此操作,最好保留注意rjust和ljust方法:"4".rjust(2,'0')这将使“4”右对齐,方法是确保它至少有2个字符长,并用“0”填充它。

javascript - 为什么使用 Number.parseInt 而不是 parseInt()?

来自documentation:ThismethodbehavesidenticallytotheglobalfunctionparseInt()但是,由于它是实验性的,thecompatibility最差。例如,在IE或Safari中不可用。那么,开发人员为什么要使用Number.parseInt()? 最佳答案 鼓励使用Number.parseInt而不是parseInt()是因为JavaScript社区有一种远离使用全局变量的趋势。关于Number.parseInt的Mozilla文档指出:...andispartofECMA