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: .

203 questions
74
votes
5 answers

Dividing elements of a ruby array into an exact number of (nearly) equal-sized sub-arrays

I need a way to split an array in to an exact number of smaller arrays of roughly-equal size. Anyone have any method of doing this? For instance a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] groups = a.method_i_need(3) groups.inspect =>…
Red
  • 2,256
  • 5
  • 25
  • 38
50
votes
6 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
  • 24,318
  • 13
  • 79
  • 133
39
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
  • 1,004
  • 2
  • 13
  • 28
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,372
  • 3
  • 24
  • 31
12
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
  • 21,401
  • 12
  • 79
  • 130
9
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
  • 91
  • 1
  • 4
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
  • 29,626
  • 15
  • 79
  • 79
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,819
  • 2
  • 16
  • 25
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,101
  • 4
  • 34
  • 44
6
votes
2 answers

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,498
  • 1
  • 12
  • 22
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,692
  • 3
  • 24
  • 28
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
  • 8,510
  • 12
  • 51
  • 93
4
votes
1 answer

Enumerable::each_with_index now optionally takes a arguments in Ruby 1.9. What significance and/or what is a use case for that?

In Ruby 1.8.7 and prior, Enumerable::each_with_index did not accept any arguments. In Ruby 1.9, it will accept an arbitrary number of arguments. Documentation/code shows that it simply passes those arguments along to ::each. With the built in and…
Ryan
  • 2,073
  • 1
  • 19
  • 33
4
votes
4 answers

Uncaught ReferenceError: check is not defined

Please help me out with this, jquery is working well in w3schools but in my rails 2 app its getting error like check not defined Here is my html code: Checkbox:
Hemanth M C
  • 436
  • 1
  • 4
  • 18
4
votes
2 answers

DBI Row / delegate behavior between ruby 1.8.7 and 2.1

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…
Rajat
  • 1,766
  • 2
  • 21
  • 42
1
2 3
13 14