Questions tagged [ruby-1.8.7]

For issues relating to developing in Ruby, version 1.8.7.

Use this specific tag along with the generic one: .

202 questions
64
votes
5 answers

Splitting an array into equal parts in ruby

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]]
Red
  • 2,096
  • 5
  • 21
  • 36
44
votes
5 answers

Ruby Output Unicode Character

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…
Jeremy Harris
  • 23,007
  • 13
  • 73
  • 124
34
votes
8 answers

Get last character in string

I want to get the last character in a string MY WAY - 1) Get last index 2) Get character at last index, as a STRING. After that I will compare the string with another, but I won't include that part of code here. I tried the code below and I get a…
stack1
  • 894
  • 2
  • 11
  • 25
19
votes
1 answer

Ruby require 'file' and relative location

So I'm writing some rspec tests and I'm embarrassed at my lack of Ruby understanding. I have a file structure that looks like the following: GUI_Tests/Tests/test_spec.rb GUI_Tests/windows_gui.rb GUI_Tests/upload_tool.rb when I run spec for the…
Bobby B
  • 2,232
  • 3
  • 24
  • 31
9
votes
1 answer

Ruby 1.8.7 convert hash to string

I wasn't working with ruby 1.8.7 and recently I was surprised that: {:k => 30}.to_s #=> "k30" Is there ready to use fix to convert hash to string for ruby 1.8.7 to make it look like: {:k => 30}.to_s #=> "{:k=>30}"
megas
  • 20,057
  • 11
  • 70
  • 126
9
votes
1 answer

How to install Ruby 1.8.7 on OS X 10.8 Mountain Lion

I've been looking around for the best way to do this and found an easier way than to install both tcl and tk.
Tyler Brock
  • 27,248
  • 15
  • 69
  • 76
8
votes
1 answer

Rails Logfiles "not opened for writing"

I am in a process of migrating my application from ruby 1.8.7 to 1.9.3 (and later upgrading Rails). However I geht some problems with logging in 1.9.3. By using the following code in environment.rb when console or server starts up logfile =…
peter247
  • 81
  • 4
8
votes
2 answers

AASM is not working with my rails 3 and ruby 1.8.7 ( undefined method `name' for nil:NilClass )

I'm using Rails 3.2.2, with aasm gem, I have Document model this way: class Document < ActiveRecord::Base include AASM aasm do state :unread, :initial => true state :read state :closed event :view do transitions :to =>…
Eqbal
  • 1,519
  • 2
  • 14
  • 23
7
votes
3 answers

400 bad request in ruby but not curl

I'm trying to make a https post request in ruby and it works in curl, but I get a 400 bad request in ruby and I'm having trouble figuring out why. Heres the ruby code: require 'rubygems' require 'net/https' require 'uri' require 'json' uri =…
AdamB
  • 3,039
  • 3
  • 31
  • 42
5
votes
1 answer

Is there a "spawn" equivalent for Ruby 1.8.7?

Is there a spawn equivalent for ruby 1.8.7? It appears as though it was introduced in 1.9.1 http://apidock.com/ruby/Kernel/spawn I need the following to work in ruby 1.8.7: def run_worker(queue, count = 1) puts "Starting #{count} worker(s) with…
Caleb
  • 3,426
  • 2
  • 22
  • 27
5
votes
1 answer

debugging a rails app with rubymine

I have a Rails app using Ruby 1.8.7 and I'm getting this error when running in debug mode and setting a break point: 54749: Exception in DebugThread loop: undefined method `errmsg' for…
WebQube
  • 6,772
  • 9
  • 40
  • 76
4
votes
1 answer

How to set correct Ruby version in gem environment

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…
Keith Pitty
  • 1,068
  • 1
  • 7
  • 20
4
votes
3 answers

Wobble Hypothesis - Combination or Permutation of Array of strings in ruby

I have a ruby array with 4 strings nucleotides = ['A', 'G', 'C', 'T'] I need 4^3 combinations of strings. new_array = ['AGC', 'AGT' .. 'TTT'] This is the wobble hypothesis in genetics. Could someone explain how I could go about achieving this…
Stacked-for-life
  • 186
  • 1
  • 15
4
votes
3 answers

Require file only if it exists

Perhaps there's a better way to do this. I want to be able to load some routes dynamically. I was planning on having static routes in routes.rb, and custom routes in custom_routes.rb. Then at the bottom of routes.rb, I would do: CustomRoutes.create…
Josh M.
  • 23,573
  • 23
  • 96
  • 160
4
votes
1 answer

Ruby Rails webrick server using old version of ruby

ruby -v give me ruby-1.9.3-p194. which ruby gives /home/ubuntu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby rails -v gives Rails 3.2.7 which rails gives /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/bin/rails "sudo bundle exec rails s"…
StanM
  • 765
  • 2
  • 10
  • 32
1
2 3
13 14