ruby-1.8.7

Downgrading from Rails 3.2.6 to 3.0.11

怎甘沉沦 提交于 2019-12-13 04:28:09
问题 I am facing issue when I am trying to work with rails 3.0.11. I initially worked with rails 3.2.6. Build a prototype application in Rails 3.2.6, Ruby 1.9.2 and gem 1.8.7. But then found, server on which we need to host is a shared server which can only support Rails 3.0.11, Ruby 1.8.7 and gem 1.7.2. Hence I want to keep my dev environment exactly same before I ran into further issues. As I found there was some discrepancy in routes.rb of both the versions. Steps I followed: Uninstalled rails

ruby 1.8.7 to_proc creates empty arrays

这一生的挚爱 提交于 2019-12-08 10:01:00
问题 This is a follow-up to to this answer, regarding ruby 1.8.7's Symbol#to_proc generating a new proc every invocation. There seems to be more going on than the answers suggest. Here's some sample code: def ctob h=Hash.new(0) ObjectSpace.each_object(Object) {|e| h[e.class]+=1 } h end r=(0...1000) p ctob r.map(&:to_i) p ctob This reveals that about a thousand arrays are being created. This reveals that about a thousand are empty: c=0; ObjectSpace.each_object(Array){|e| c+=1 if e.empty? } Another

ruby 1.8.7 to_proc creates empty arrays

我与影子孤独终老i 提交于 2019-12-07 15:33:23
This is a follow-up to to this answer , regarding ruby 1.8.7's Symbol#to_proc generating a new proc every invocation. There seems to be more going on than the answers suggest. Here's some sample code: def ctob h=Hash.new(0) ObjectSpace.each_object(Object) {|e| h[e.class]+=1 } h end r=(0...1000) p ctob r.map(&:to_i) p ctob This reveals that about a thousand arrays are being created. This reveals that about a thousand are empty: c=0; ObjectSpace.each_object(Array){|e| c+=1 if e.empty? } Another interesting thing is that only one Proc object exists. This suggests that to_proc is only called once.

DBI Row / delegate behavior between ruby 1.8.7 and 2.1

╄→гoц情女王★ 提交于 2019-12-04 14:22:47
I execute the following code in ruby 1.8.7 to read rows from my database: require 'dbi' db_conn_handle = DBI.connect("DBI:Mysql:host=localhost;database=mydb;port=3306", "root") sth = db_conn_handle.prepare("select accounts.id, accounts.name from accounts;") sth.execute info = sth.to_a puts "Info: #{info[0].class}" info.each do |x, y| puts "#{x} ... #{y}" end From the output it is clear that info[0].class is DBI::Row. This code works perfectly when executed with ruby 1.8.7 (rails 3.2.17) When I try executing it in ruby 2.1.5 / rails 3.2.17, it gives the following error: /home/rjain/.rvm/rubies

How to set correct Ruby version in gem environment

这一生的挚爱 提交于 2019-12-02 00:04:06
问题 Note: This question relates to How can I get bundler to use the Ruby version set by chruby and .ruby-version?. Using chruby I have Ruby 1.8.7 installed on macOS: $ ruby -v ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0] Also, I have used gem update --system 1.8.30 to install a specific version of RubyGems which I am hoping is compatible. This would appear to be installed properly: $ gem --version 1.8.30 However, my RubyGems environment shows the incorrect version of Ruby (2.5.0): $

How to set correct Ruby version in gem environment

梦想与她 提交于 2019-12-01 20:33:27
Note: This question relates to How can I get bundler to use the Ruby version set by chruby and .ruby-version? . Using chruby I have Ruby 1.8.7 installed on macOS: $ ruby -v ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0] Also, I have used gem update --system 1.8.30 to install a specific version of RubyGems which I am hoping is compatible. This would appear to be installed properly: $ gem --version 1.8.30 However, my RubyGems environment shows the incorrect version of Ruby (2.5.0): $ gem env RubyGems Environment: - RUBYGEMS VERSION: 1.8.30 - RUBY VERSION: 2.5.0 (2017-12-25 patchlevel

Ruby Output Unicode Character

旧巷老猫 提交于 2019-11-30 11:47:01
问题 I'm not a Ruby dev by trade, but am using Capistrano for PHP deployments. I'm trying to cleanup the output of my script and am trying to add a unicode check mark as discussed in this blog. The problem is if I do: checkmark = "\u2713" puts checkmark It outputs "\u2713" instead of ✓ I've googled around and I just can't find anywhere that discusses this. TLDR: How do I puts or print the unicode checkmark U-2713? EDIT I am running Ruby 1.8.7 on my Mac (OSX Lion) so cannot use the encode method.

Ruby Output Unicode Character

会有一股神秘感。 提交于 2019-11-30 01:17:52
I'm not a Ruby dev by trade, but am using Capistrano for PHP deployments. I'm trying to cleanup the output of my script and am trying to add a unicode check mark as discussed in this blog . The problem is if I do: checkmark = "\u2713" puts checkmark It outputs "\u2713" instead of ✓ I've googled around and I just can't find anywhere that discusses this. TLDR: How do I puts or print the unicode checkmark U-2713? EDIT I am running Ruby 1.8.7 on my Mac (OSX Lion) so cannot use the encode method. My shell is Bash in iTerm2. UPDATE [4/8/2019] Added reference image in case site ever goes down.

Splitting an array into equal parts in ruby [duplicate]

好久不见. 提交于 2019-11-28 18:32:01
This question already has an answer here: How to chunk an array in Ruby 2 answers I need a way to split an array in to a bunch of arrays within another array of equal size. Anyone have any method of doing this? For instance a = [0, 1, 2, 3, 4, 5, 6, 7] a.method_i_need(3) a.inspect => [[0,1,2], [3,4,5], [6,7]] You're looking for Enumerable#each_slice a = [0, 1, 2, 3, 4, 5, 6, 7] a.each_slice(3) # => #<Enumerator: [0, 1, 2, 3, 4, 5, 6, 7]:each_slice(3)> a.each_slice(3).to_a # => [[0, 1, 2], [3, 4, 5], [6, 7]] Perhaps I'm misreading the question since the other answer is already accepted, but it