Questions tagged [ruby-1.8]

For issues relating to developing in Ruby, version 1.8. If your question applies to Ruby in general, use the tag [tag:ruby].

Ruby is an open-source dynamic object-oriented interpreted language created by Yukihiro Matsumoto (Matz) in the 1990s.

Related tags:

140 questions
5
votes
2 answers

Ruby Net::HTTP - Stop automatically escaping quotes?

I have the following code: http = Net::HTTP.new("www.something.com", 80) http.set_debug_output($stdout) http.post("/blah", "something", {'random-parameter' => 'value1="something",value2="somethingelse"'}) Then when I read the output…
n s
  • 1,361
  • 2
  • 12
  • 24
5
votes
1 answer

What is this macro?

In ruby.h, there are a lot of function macros defined like this: static inline int #if defined(HAVE_PROTOTYPES) rb_type(VALUE obj) #else rb_type(obj) VALUE obj; #endif { if (FIXNUM_P(obj)) return T_FIXNUM; …
NickWEI
  • 59
  • 2
5
votes
5 answers

Rails render partial in a loop

I am new to rails and I am trying to render a partial within a loop as such. Here , books is an array eager loaded in controller. books.each do |book| <%= render 'books/book', :book => book %> end This works fine. But when the books array is…
testsum
  • 51
  • 1
  • 2
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
4
votes
2 answers

Is there a Ruby 1.8.7 time.strftime %z bug?

I'm having an issue with Ruby 1.8.7 strftime where the %z is returning the local time after i convert the time to UTC. I'm doing the following: >> t = Time.now => Mon Dec 19 15:20:16 -0800 2011 >> t.strftime("%z") => "-0800" >> t =…
roloenusa
  • 761
  • 1
  • 10
  • 19
4
votes
1 answer

"test".partition("s") calls partition from Enumerable module instead of String module

I have tried to partition a string using the partition method from the String module. However, when doing so: puts "test".partition("s") I get the following error message: Line 1:in `partition': wrong number of arguments (1 for 0) (ArgumentError)…
Jan-Willem
  • 187
  • 1
  • 12
4
votes
3 answers

Why is Symbol#to_proc slower in Ruby 1.8.7?

Relative Performance of Symbol#to_proc in Popular Ruby Implementations states that in MRI Ruby 1.8.7, Symbol#to_proc is slower than the alternative in their benchmark by 30% to 130%, but that this isn't the case in YARV Ruby 1.9.2. Why is this the…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
4
votes
2 answers

ruby hash as key to a hash

Came across the following weird behaviour in ruby 1.8.6, in 1.8.7 it seems to be working correctly. Does anyone know what would have caused this? h = {} key_1 = {1 => 2} key_2 = {1 => 2} h[key_1] = 3 p key_1 == key_2 # => true p h.has_key?(key_2) #…
Jamie Cook
  • 4,375
  • 3
  • 42
  • 53
4
votes
1 answer

How to unwind (multi-level return) the stack without catch/try/raise?

I would like to unwind the stack to an arbitrary level when catch/try is not available (i.e., the code to which I'm unwinding is out of my control). Is this possible? For example, in testing, I would like to have my tests call a method that checks…
RoUS
  • 1,888
  • 2
  • 14
  • 29
4
votes
4 answers

Comparing two similar hashes in ruby

I'm using ruby 1.8.7 and I need to compare two hashes that I have, which are essentially the attributes of a model. Hash A is smaller than Hash B, and Hash B has all of the attributes of hash A, plus some extra attributes I don't care about. My…
Mysrt
  • 3,044
  • 2
  • 17
  • 14
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
4
votes
6 answers

What's discouraging you from writing ruby 1.9-specific code?

So far, I've been merely using YARV (ruby 1.9) as merely a faster implementation of ruby than ruby 1.8, and ensured that all of my code is backwards-compatible with ruby 1.8.6. What circumstances, if any, are stopping you from writing 1.9-specific…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
4
votes
1 answer

How does `?n` differ from `'n'`?

Chris Pine's How to Program mentions that the following: ?T should return 84. When I run it, it returns "T". My suspicion is that there is a version difference. My guess is that ? is an Array or String method, but I cannot find documentation. What…
notthehoff
  • 1,172
  • 1
  • 12
  • 28
4
votes
2 answers

Getting error "Cannot allocate memory" for Rails

In my project there is one script that returns the list of products which I have to display in a table. To store the input of the script I used IO.popen: @device_list = [] IO.popen("device list").each do |device| @device_list <<…
user2622247
  • 1,059
  • 2
  • 15
  • 26
4
votes
2 answers

Call Ruby 1.8 script from Ruby 2.0 script

I'm not sure if this belongs here or somewhere else (SuperUser?) but anyway: I've got two Ruby scripts, one which requires Ruby 2.0 (A) and another which requires 1.8 (B). A needs to call B with a forked processes. A is something like this: require…
JacobEvelyn
  • 3,901
  • 1
  • 40
  • 51
1
2
3
9 10