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
2
votes
1 answer

How to get the i'th character from utf-8 String in Ruby 1.8.7?

Given the following constant: RUSSIAN_LOWERCASE_ALPHABET = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя" When trying to get one letter: content_tag(:span, RUSSIAN_LOWERCASE_ALPHABET[0]) Ruby 1.9.2 does the work as expected (I see the letter in a browser),…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
2
votes
1 answer

Why begin/rescue/else behaves differently on 1.9.2 and 1.8.7

I am working with the method mm. In ruby 1.9.2 it behaves weird, instead of the expected result 1.9.2=>10 I am getting ELSE ** 1.9.2=>8 Any idea of what is going on? class A def mm(data) begin send_len = data return send_len …
user454322
  • 7,300
  • 5
  • 41
  • 52
2
votes
4 answers

Is there an equivalent of Array#each_slice() in Ruby 1.8.5?

I'm using ruby 1.8.5, and the each_slice() method for an array is not working. My code is something like: array.each_slice(3) do |name,age,sex| ..... end Is there any other way to implement the same functionality in my older version of ruby.
sundar
  • 369
  • 2
  • 4
  • 10
2
votes
1 answer

Avoid ActiveRecord#save logging of large fields

I need to prevent ActiveRecord#save from logging the content of large fields. Is there a way to configure this on Rails 2.3.x? @document.save #=> Will log something like: Apr 20 13:45:42 ubuntu rails[2619]: Document::HTML Update (7.0ms) UPDATE…
Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110
2
votes
2 answers

DRY double in RSpec

How to DRY(don't repeat yourself) the double in RSpec? For example: let(:s1) {instance_double(Class1, :attr1 => val1, :attr2 => val2, :attr3 => val3, …
laahaa
  • 327
  • 3
  • 12
2
votes
2 answers

Rails - query a different mysql db to the standard app db

I'm using Rails 2.2.2 and Ruby 1.8.6 with a legacy app, with MySQL. (please don't tell me that I need to upgrade ruby/rails). I have backups of our live database installed as different databases within my local MySql. This is useful sometimes for…
Max Williams
  • 32,435
  • 31
  • 130
  • 197
2
votes
1 answer

How to display unicode characters using curses?

I am currently using this code for a test console, but unicode chars are always completely broken (even more in 1.9 then 1.8.7) # encoding: UTF-8 require 'curses' Curses.noecho # do not show typed chars Curses.nonl # turn off newline…
grosser
  • 14,707
  • 7
  • 57
  • 61
2
votes
3 answers

Ruby 1.8 and UTF-8 string case statement compare

I have a Rake task (in lib/tasks directory) that I run with cron on my shared web hosting. The problem is that I want to compare a UTF-8 string using case statment but my source code is not UTF-8 encoded. If I save source code as UTF-8 there is…
Julian Popov
  • 17,401
  • 12
  • 55
  • 81
2
votes
3 answers

Ruby - How to invert a Hash with an array values?

Looking for an answer that works on Ruby 1.8.7 : For example lets say I have a hash like this: {"Book Y"=>["author B", "author C"], "Book X"=>["author A", "author B", "author C"]} and I want to get this: { "author A" => ["Book X"], "author…
JQuack
  • 21
  • 4
2
votes
1 answer

How do I use Ruby's SOAP::Attachment class?

So I'm writing a Ruby client for a SOAP web service, and I've figured out how to call a simple method: # WebServiceClient.rb require 'soap/wsdlDriver' wsdl_url = 'http://urlmadness?wsdl' service =…
Alex Moore
  • 3,415
  • 1
  • 23
  • 39
2
votes
2 answers

Ruby 101: How Can I Save, Read, Write, then Save the Contents of an Array?

Thank you for taking the time to review and perhaps advise on my simple question. I'm seeking a solution for an exercise on which I'm working. I'd like to know how to write the contents of this array: @points = [1, 2, 3, 4] to this…
user2448377
  • 69
  • 1
  • 6
2
votes
1 answer

How do you invoke ruby module methods via reflection?

I'd like to get the following to work. The idea is that I can add methods to Routes and if they exist I can use them later. I'm using Ruby 1.8. module Routes def home #stuff end def work #end end end Routes.method_defined? :home #…
reconbot
  • 5,138
  • 6
  • 45
  • 63
2
votes
1 answer

RVM and Passenger with two Ruby versions

How can I use Passenger, RVM and Apache with 1.9 and 1.8(ree) ruby version? I need it in production env. I try this: RVM PASSENGER but REE is only working. 1.9 say this: The given ruby environment requires ruby-1.9.2-p318 (versus …
quatermain
  • 1,442
  • 2
  • 18
  • 33
2
votes
1 answer

What's the text encoding used for header values on HTTP requests?

I have a Ruby on Rails application that is a server for Java and .Net apps. I have a custom header I'm using to send some data, but when this data reaches the Ruby on Rails app, Rails reads the value as UTF-8 then says the value is not a valid UTF-8…
Maurício Linhares
  • 39,901
  • 14
  • 121
  • 158
1
vote
1 answer

Rework ruby 1.8 encoding conversion code to ruby 1.9

How can I convert the following deprecated ruby 1.8 code into ruby 1.9 code? invalid_chars_stripper = Iconv.new('UTF-8//IGNORE', 'UTF-8') invalid_chars_stripper.iconv(body + ' ')[0..-2] Thanks.
Bogdan Gusiev
  • 8,027
  • 16
  • 61
  • 81