-1

I'm making an application to obtain a "key" using tideSDK with ruby. TideSDK support ruby 1.8.7, so I'm using ruby 1.8.7, whatever.

I'm following this wiki for using tideSDK with ruby

I have index.html file looks like this :

<script type="text/ruby">  
require 'enumerator'

def gen_key(name, acc_type) 
   name = name.gsub(/[^A-Za-z0-9]/,"").upcase
   acc_type = acc_type.upcase
   name_array = name.split("")
   data = [0, 0, 0]
   name_array.each_slice(3) do |i|
      i.each_with_index do |j, index|
          data[index] += j.ord*name.length
      end
   end
   # other stuff here for return key
end
</script>
<form id="myForm" action="javascript:getKey();">
 <input type="text" name="name" id="name"/>
 <input type="text" name="type" id="type"/>
    <input type="submit"/>
</form>
<script src="jquery.min.js"></script>
<script>
function getKey(){
        var values = {};
        $.each($('#myForm').serializeArray(), function(i, field) {
            values[field.name] = field.value;
        });
        alert(gen_key(values['name'], values['type']));
}
</script>

when I launch my app and submit the form, I getting error on console :

Error: undefined method `ord' for "T":String

btw, Thanks for downvote, now I know ord doesn't exist in ruby 1.8, and I'm using this

data[index] += j[0]*name.length
itx
  • 1,327
  • 1
  • 15
  • 38

1 Answers1

3

Looks like this is linked to this line:

data[index] += j.ord*name.length

You are calling an "ord" method which does not exist in String in Ruby 1.8.7. Ord does exist in 1.9.3.

sawa
  • 165,429
  • 45
  • 277
  • 381
Martin
  • 7,634
  • 1
  • 20
  • 23