草庐IT

getting-the-windows-os-version-in

全部标签

ruby - 我可以在 OS X v10.6.8 上升级到当前版本的 Ruby (2.2.3) 吗?

我正在查看“InstallRubyonRails·MacOSXYosemite”,在说明中它说要更新您的操作系统,但我真的不想这样做,因为我的计算机正在老化。我还找到了“HowtoupdateRubyto1.9.xonMac?”。据我所知,我没有RVM,我害怕再安装一次,以防我的系统要求仍然不够好。最终,我正在尝试更新Jekyll,但我需要先更新我的系统。我需要Ruby1.9.3或更高版本。请问“如何在Mac上将Ruby更新到1.9.x?”工作?我正在运行Ruby1.8.7(2012-02-08补丁级别358)[universal-darwin10.0]'。编辑:我最终安装了RVM。对

ruby-on-rails - Rails has_many :through Find by Extra Attributes in Join Model

Ruby和Rails的新手,但我现在已经受过书本教育(这显然没有任何意义,哈哈)。我有两个模型,Event和User通过表EventUser连接classUser:event_usersendclassEventUser:event_usersend这个项目是一个日历,我必须在其中跟踪人们为给定的事件注册和刮掉他们的名字。我认为多对多是一种好方法,但我不能这样做:u=User.find:firstactive_events=u.events.find_by_active(true)因为事件实际上没有额外的数据,所以EventUser模型有。虽然我可以做到:u=User.find:fir

ruby-on-rails - rails : How I can get yesterday's date?

如何获取昨天的日期?也许:@get_time_now=Time.now.strftime('%m/%d/%Y')/86400或@get_time_now=Time.now.strftime('%m/%d/%Y')-1.day或@get_time_now=Time.now./8640086400=1天,对吧?(60*60*24) 最佳答案 rails对于日期对象,您可以使用:Date.yesterday或者一个时间对象:1.day.agoruby或者在rails之外:require'date'Date.today.prev_day

ruby - `gem install therubyracer` 在 Mac OS X Lion 上失败

我将不胜感激让geminstalltherubyracer正常工作。这是错误:$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./Users/david/.rvm/rubies/ruby-1.9.3-p194/bin/rubyextconf.rbcheckingformain()in-lobjc...yes***extconf.rbfailed***Cou

ruby-on-rails - 如何修复 "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0"

我创建了一个Ruby项目,但是在运行bundleupdate和bundleinstall时返回错误:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0它的图像是:http://i.imgur.com/dZMhI11.png?1我的gemfile是:ruby'2.0.0'#ruby-gemset=railstutorial_rails_4_0gem'rails','4.0.0'group:developmentdogem'sqlite3','1.3.8'endgem'sass-rails','4.0.0'gem'uglifier','2

ruby - 如何在 Mac OS Sierra 10.12 上安装 Nokogiri

我在MacOSSierra10.12上安装Nokogiri(1.6.8.1)时遇到问题。我尝试使用brewinstalllibxml2libxslt然后使用命令行选项引用安装目录,但没有帮助。 最佳答案 打开Xcode,然后从菜单XCode->Preferences更新您的命令行工具(Xcode8.0)。然后做:bundleconfigbuild.nokogiri--use-system-libraries=true--with-xml2-include="$(xcrun--show-sdk-path)"/usr/include/l

ruby-on-rails - 如何在 rake 任务中使用 "gets"?

每当我尝试在rake任务中使用函数gets时,我都会收到错误消息。有没有办法让它发挥作用?错误说,“没有这样的文件或目录-(rake任务名称)” 最佳答案 问题是Kernel#gets(如果你只是单独使用gets,这就是你所调用的)假设你正在从一个由传递给Rake的参数命名的文件中提取。这意味着gets尝试返回名为[rake-task-here]的文件的内容,该文件几乎肯定不存在。尝试STDIN.gets. 关于ruby-on-rails-如何在rake任务中使用"gets"?,我们在S

ruby-on-rails - 为什么 rake db :migrate:reset not listed in rake -T?

为什么rake-T没有列出一些rake任务?像db:migrate:reset吗?我可以毫无问题地执行它,但为什么它没有列在那里?有没有办法获得真正完整的rake任务列表?%rake-T(in/home/zeus/projects/my_project)rakeabout#ListversionsofallRailsframeworksandtheenvironmentrakedb:create#Createthedatabasefromconfig/database.ymlforthecurrentRails.env(usedb:create:alltocreatealldbsint

ruby - "which in ruby": Checking if program exists in $PATH from ruby

我的脚本严重依赖外部程序和脚本。我需要确定我需要调用的程序存在。手动地,我会在命令行中使用“which”来检查这一点。对于$PATH中的东西,是否有等同于File.exists?的东西?(是的,我想我可以解析%x[whichscriptINeedToRun]但这不是super优雅。谢谢!亚尼克更新:这是我保留的解决方案:defcommand?(command)system("which#{command}>/dev/null2>&1")end更新2:出现了一些新的答案-至少其中一些提供了更好的解决方案。更新3:ptoolsgem向File类添加了一个“which”方法。

ruby - 使用 Net::HTTP.get 获取 https url

我正在尝试将Net::HTTP.get()用于httpsURL:@data=Net::HTTP.get(uri,Net::HTTP.https_default_port())但是,当我尝试打印结果时得到以下结果:can'tconvertURI::HTTPSintoString这是怎么回事?我正在使用Ruby1.8.7(OSX) 最佳答案 原答案:uri=URI.parse("https://example.com/some/path")http=Net::HTTP.new(uri.host,uri.port)http.use_ssl