# "Can't convert string to number" - error

**URL:** <https://www.ruby-forum.com/t/cant-convert-string-to-number-error/117166>\
**Category:** Rails\
**Created:** [October 14, 2007, 4:44am UTC](https://www.ruby-forum.com/t/cant-convert-string-to-number-error/117166 "2007-10-14T04:44:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikrant\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e5b9ba/32.png) [@Vikrant\_C](https://www.ruby-forum.com/u/Vikrant_C)\
**Post date:** [October 14, 2007, 4:44am UTC](https://www.ruby-forum.com/t/cant-convert-string-to-number-error/117166/1 "2007-10-14T04:44:50Z")

</div>

Hi,  
I have a Model for my\_table table  
which serialises a column named serialised\_column  
serialised\_column contains an array object, which contains hash objects  
something like  
serialised\_column = [{‘name’ =\> ‘this’}, {‘name’ =\> ‘that’}]

the code for model is something like this

class MyTable \< ActiveRecord::Base  
set\_table\_name ‘my\_table’  
serialize :serialised\_column  
end

and a controller which access the data  
class ShowController \< ApplicationController  
def show  
s = MyTable.find(:all, :conditions =\> [‘some conditions’])  
if s.size != 0  
@s = []  
s.serialised\_column.each { |s|  
@s \<\< [‘name’ =\> s[‘name’]]  
}  
end #if  
end #def  
end #class

in view the show.rhtml file is something like  
\<%# considering size of s is not zero  
%\>  
\<%= @s[0][‘name’] %\>

now when I run this file, I get an TypeError exception, which says  
‘can’t  
convert String into Integer’  
why is so? I’m not casting a string to intger, and neither want it to  
happen!

---

<div class="post-metadata">

**Author:** ![Vikrant\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e5b9ba/32.png) [@Vikrant\_C](https://www.ruby-forum.com/u/Vikrant_C)\
**Post date:** [October 14, 2007, 5:05am UTC](https://www.ruby-forum.com/t/cant-convert-string-to-number-error/117166/2 "2007-10-14T05:05:16Z")

</div>

you’re pushing arrays onto @s: @s \<\< [‘name’ =\> s[‘name’]]

with your current structure you’d have to access them like  
@s[0][0]['name]

maybe instead you can just push hashes: @s \<\< {‘name’ =\> s[‘name’]}

---

<div class="post-metadata">

**Author:** ![Vikrant\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e5b9ba/32.png) [@Vikrant\_C](https://www.ruby-forum.com/u/Vikrant_C)\
**Post date:** [October 14, 2007, 5:08am UTC](https://www.ruby-forum.com/t/cant-convert-string-to-number-error/117166/3 "2007-10-14T05:08:11Z")

</div>

Thanks, I got it. Its working now. thanks again.
