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
1
vote
2 answers

How to print keys and values from a text file

I have a file called "output.txt": "name": "abc", "age": 28, "name": "xxx", "age": 11, "name": "yyyb", "age": 15, I want to read the file and print the name and age values on one line, one after the other: abc 28 xxx 11 yyyb…
user1642224
  • 61
  • 14
1
vote
3 answers

Transform 2D array into hash

I have a sorted 2D array as follows: a = [[1, 2011], [3, 1999], [4, 2014], [6, 1998], ...] How can I transform this into a hash with the key being the year and the value being the number in front? {2011 => 1, 1999 => 3, 2014 => 4, 1998 => 6, ...}
Alan1
  • 83
  • 1
  • 4
1
vote
1 answer

rails-i18n translations not loading the exact data

I am using ruby 1.8.7 and i18n gem version 0.4.2 , In view page i have used

<%= " #{t('date')} :"%>

and at en.yml en: # locale net: "Net" amount_paid: "Paid Amount" date: "Date" when i executed I got this Why I am not…
Sanju B Myh
  • 271
  • 1
  • 15
1
vote
1 answer

How to count the no of rows and read the data in Excel sheet(.xlsx) in ruby using win32ole gem

I have a excel sheet(.xlsx) format which has only text data,I want to count the no of rows as well read the text data from the excel sheet in ruby using win32ole gem only.I have gone through many of the post in stackoverflow which represent these…
shaik
  • 143
  • 11
1
vote
1 answer

Using unsupported ruby binary interpreters with Rails LTS

I've done a little bit of reading and I can't seem to find a good answer to this question. I wanted to know if somebody could comment if there are any known dangers to using Rails LTS (https://railslts.com) with an unsupported (i.e. unpatched) Ruby…
a2f0
  • 1,615
  • 2
  • 19
  • 28
1
vote
1 answer

Why does an empty ERB file cause a warning in Ruby 1.8.7?

I understand what the following warning means: -:1: warning: useless use of a variable in void context But I don't understand why ERB in Ruby 1.8.7 generates code that uses _erbout variable in void context: $ rvm use ruby 1.8.7 Using…
Radek Simko
  • 15,886
  • 17
  • 69
  • 107
1
vote
0 answers

How to include polymorphic association in 'includes' Rails

I have this in model: belongs_to :merchant_owner, :polymorphic => true I want to make query like this: @search = Merchant.includes(:merchant_owner).search @merchants = @search.order But I get this error in views: You can't create a…
1
vote
2 answers

Ruby on Rails - Get array of values from array of hash with particular order of existing keys

The original array likes this: [{:age=>28, :name=>"John", :id=>1}, {:name=>"David", :age=>20, :id=>2, :sex=>"male"}] Order of existing keys: [:id, :name, :age] or ['id', 'name', 'age'] The result should be: [[1, "John", 28], [2, "David",…
Anh
  • 27
  • 1
  • 6
1
vote
1 answer

uninitialized constant HTTPSuccess (NameError)

I am trying to learn some ruby http request response code from this tutorial - http://danknox.github.io/2013/01/27/using-rubys-native-nethttp-library/ Code so far - require "net/http" require "uri" uri = URI.parse("http://api.random.com") http =…
stack1
  • 1,004
  • 2
  • 13
  • 28
1
vote
0 answers

Rake task not able to send mail by requiring 'roo' Rails

I am writing a rake task for importing data from Csv, Xls and Xlsx for with Roo '1.9.1' ruby '1.8.7' and Rails '2.3.18'. It works fine with all the data import and processing. At the top of the file I have require 'iconv' require 'roo' I am…
Madhusudhan
  • 98
  • 11
1
vote
1 answer

Match all symbols except emoticons

I use Ruby 1.8.7 I have a regex that is valid in Ruby 1.8.7 to match all emoticons /\|?>?[:*;Xx8=<(%)D]-?'?,?o?\_^?[-DOo0S*Ppb3c:;\/\\|)(}{\]><]\)?|\(/ However , I want to match all set of symbols except the ones in this regex For example,the…
Prateek Narendra
  • 1,837
  • 5
  • 38
  • 67
1
vote
3 answers

How can I push consecutive same elements into subarrays?

For example, input = ['a','b','b','b','a','a','b','c','c'] output = ['a',['b','b','b'],['a','a'],'b',['c','c']] Here, if there are more than one same elements then those are put into sub-array. Can you please help me out?
1
vote
1 answer

Regex don't find matches in Ruby 1.8.7 but does in 1.9.2

I'm trying to validate UK zip codes in Ruby. I stumbled upon this regex on stackoverflow: (GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY]))))…
Akki209
  • 123
  • 12
1
vote
2 answers

Get full path to file from within migration

I need to insert the contents of a file into the database during a migration (Rails 3.2.13). What's the proper way to reference a file that is elsewhere in the project? db/migrate/the_migration.rb class ... content =…
Josh M.
  • 26,437
  • 24
  • 119
  • 200
1
vote
2 answers

time.now now in ruby 1.8.7 vs ruby 2?

Currently i am upgrading my application from ruby 1.8.7 to ruby 2. I got the following issue datetime. Ruby 1.8.7 console: u=User.find :last => #
kannathasan
  • 565
  • 7
  • 21