草庐IT

version_number

全部标签

ruby - 在 gem --version 之后运行时获取 "isn' t a Gem::Specification(改为 NilClass)

$gem--version[/home/rohit/.rvm/gems/ruby-1.9.3-p125@qnrDashboard/specifications/net-ssh-2.5.2.gemspec]isn'taGem::Specification(NilClassinstead).[/home/rohit/.rvm/gems/ruby-1.9.3-p125@qnrDashboard/specifications/net-sftp-2.0.5.gemspec]isn'taGem::Specification(NilClassinstead).[/home/rohit/.rvm/ge

ruby - 如何停止使 tmux 自动设置 RBENV_VERSION

当我启动tmux时,tmux会自动设置RBENV_VERSION...有人知道怎么阻止吗?因为它会自动设置,所以我需要做$导出RBENV_VERSION取消设置并使.ruby-version工作。谢谢。 最佳答案 tmux本身永远不会自行设置(或取消设置)RBENV_VERSION。您有一些配置导致了这种情况。我的猜测是RBENV_VERSION是在您启动tmux服务器时设置的,它现在是tmux“全局环境”(所有继承的基础环境)的一部分tmux启动的进程)。你可以检查这个tmuxshow-environment-g|grepRBEN

ruby - "wrong number of arguments"使用圆形时出现 ArgumentError

我正在尝试将温度从华氏度转换为摄氏度:puts'ConvertirgradosFahrenheitaCelcius'STDOUT.flushx=gets.chompaprox=(x*100.0).round(2)/100.0resultado=(aprox-32)/1.8putsresultado我使用正确的公式将华氏度转换为摄氏度:Celsius=Fahrenheit-32/1.8但是,当我在控制台中运行它时,出现以下错误:`round':wrongnumberofarguments(1for0)(ArgumentError)我尝试过不同的方法,但我不明白为什么这不起作用。

ruby-on-rails - Rails number_to_currency 删除小数点右边的尾随零

我有一个动态生成的表格,它乘以价格*数量。部分价格以美分计算。例如如果某件商品的价格是0.0375,我可以在我的表格中将其显示为number_to_currency(0.0375,:precision=>4)=>$0.0375但是我得到的价格是标准的2位小数的数量number_to_currency(33.95,:precision=>4)=>$39.9500我需要一种方法来去除十进制值的尾随零。请记住,输出位于Model.eachblock中,因此我不确定是否可以有条件地修改精度参数。 最佳答案 尝试指定strip_insigni

ruby-on-rails - rake 数据库 :migrate is being aborted due to rake version difference

这个问题在这里已经有了答案:YouhavealreadyactivatedX,butyourGemfilerequiresY(11个答案)关闭8年前。我遇到了错误rakedb:migrate--tracerakeaborted!Youhavealreadyactivatedrake10.1.1,butyourGemfilerequiresrake10.1.0.Usingbundleexecmaysolvethis./Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:

ruby 任务 : joining numbers to intervals

我有一组唯一编号。像这样:[1,2,3,4,7,8,10,12]。它可以是未排序的。我需要的是获取此数组的间隔:intervals_for[1,2,3,4,7,8,10,12]#=>"1-4,7-8,10,12"我有自己的解决方案:defintervals_for(array)array.sort!new_array=[]array.eachdo|a|ifnew_array.lastanda==new_array.last.last+1new_array.last1?"#{a.first}-#{a.last}":a.first}.join(",")end但我认为这里有更干净的解决方案

ruby-on-rails - rails - postgres 错误 : Reason: Incompatible library version: libpq. 5.dylib 需要 1.0.0 或更高版本,

我无法在我的Mac(10.6.8)上设置Ruby(1.9.3)、Rails和Postgres(9.0.8)。每次运行railsconsole时,我都会收到以下错误:/Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/pg-0.13.2/lib/pg.rb:4:in`require':dlopen(/Users/dc/.rvm/gems/ruby-1.9.3-head@global/gems/pg-0.13.2/lib/pg_ext.bundle,9):Librarynotloaded:@loader_path/../lib/libssl.dy

ruby - 如何在 Ruby 中将整数舍入到 <nearest large number>?

假设我有以下任何一个数字:230957或83487或4785在Ruby中有什么方法可以将它们返回为300000或90000或分别是5000? 最佳答案 defround_up(number)divisor=10**Math.log10(number).floori=number/divisorremainder=number%divisorifremainder==0i*divisorelse(i+1)*divisorendend用你的例子:irb(main):022:0>round_up(4785)=>5000irb(main):

ruby-on-rails - rails : Why do I get "warning: already initialized constant JSON::VERSION" when running rake cucumber?

我刚刚设置了一个LinuxMintbox,用于使用rvm进行Rails开发。我继续生成了一个Rails5应用程序,设置了mysql连接,添加了cucumber-railsgem然后尝试运行:rakecucumber出于某种原因,我遇到了:/usr/bin/ruby2.3-Sbundleexeccucumber--profiledefault/usr/lib/ruby/vendor_ruby/json/version.rb:3:warning:alreadyinitializedconstantJSON::VERSION/var/lib/gems/2.3.0/gems/json-1.8.

ruby-on-rails - 参数错误 : wrong number of arguments (1 for 2)

我是Rails、MVC和CRUD的新手,我正在尝试使用更新方法来更改帖子的投票数量。我的PostsController更新方法中有以下代码:defupdate@post=Post.find(params[:id])ifparams[:vote]=='up'@post.update_column(:ups=>@post[:ups]+1)elsifparams[:vote]=='down'@post.update_column(:downs=>@post[:downs]+1)endflash[:notice]="Thanksforvoting!Thishelpsusdetermineimp