zaidmarji
asked on
Issue with Ruby script
Hi Folks,
I just inherited a ruby script that I'm trying to get to run. It goes through a couple of files and tries to match rules in one file to columns in the other file I'm coming across an issue where I get the following error
C:/Ruby187/lib/ruby/1.8/os truct.rb:8 3: [BUG] object allocation during garbage collection phase
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
Here is the piece of code it is failing on
it breaks in the most inner loop. Any idea on why this might be happening?
Thanks your help is very much appreciated.
I just inherited a ruby script that I'm trying to get to run. It goes through a couple of files and tries to match rules in one file to columns in the other file I'm coming across an issue where I get the following error
C:/Ruby187/lib/ruby/1.8/os
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
Here is the piece of code it is failing on
for line in product_lines do
tiebreaker_columns.current_row = line.strip.split("\t")
tiebreaker_columns.current_line_number = line_number
vendor = compose_tie_breaker(tiebreaker_columns)
column = 0
att_count = 0
for item in tiebreaker_columns.current_row do
t = OpenStruct.new
t.vendor_name, t.vendor_id = vendor.name, vendor.vid
t.field_name = product_vals[column]
for k,v in $rules do
if (k == t)
found_matching_rule +=1
x = OpenStruct.new
x.vid = vendor.vid.to_s().strip
x.row_id = line_number.to_s().strip
x.attribute_type = v.our_type.to_s().strip
x.attribute_name = v.our_field_name.to_s().gsub("'","''").strip
$attributes[x] = item.to_s().gsub("'","''").strip
end
att_count+=1
end
column += 1
end
line_number += 1
end
it breaks in the most inner loop. Any idea on why this might be happening?
Thanks your help is very much appreciated.
ASKER
@ JESii
Thanks I actually upgraded to 1.9.2 to try and see if it would work. The only problem I'm facing right now is trying to connect this to a MS Sql database. With 1.8.7 I could you dbd-odbc, but I dont see they have a version for 1.9.2 that runs on Windows. Any ideas?
Thanks I actually upgraded to 1.9.2 to try and see if it would work. The only problem I'm facing right now is trying to connect this to a MS Sql database. With 1.8.7 I could you dbd-odbc, but I dont see they have a version for 1.9.2 that runs on Windows. Any ideas?
Never tried that particular combination... Check these out:
http://www.codecapers.com/post/using-ruby-with-sql-server.aspx
http://rhnh.net/2010/10/10/rails-3-ruby-1-9-2-windows-2008-and-sql-server-2008-tutorial
http://ruby5.envylabs.com/episodes/121-episode-119-october-12-2010/stories/1041-rails-3-ruby-1-9-2-windows-2008-and-sql-server-2008-tutorial
HTH...
http://www.codecapers.com/post/using-ruby-with-sql-server.aspx
http://rhnh.net/2010/10/10/rails-3-ruby-1-9-2-windows-2008-and-sql-server-2008-tutorial
http://ruby5.envylabs.com/episodes/121-episode-119-october-12-2010/stories/1041-rails-3-ruby-1-9-2-windows-2008-and-sql-server-2008-tutorial
HTH...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome; I'm sorry to hear that as I'm developing a rails app to go against MS SQL Server and I'm hoping to use 1.9.2... we'll see how much "fun" I can have :=)
ASKER
no solution found so changed the code in question
Couple of suggestions:
1. Do you have the latest version of the gems you are using? If not, you could try updating them.
2. Maybe you could try upgrading to the latest Ruby version - 1.9.2? It certainly is stable and is the way to go for the future. Only problem is, there were some changes in some of the language syntax, so that might not work out of the box for you.