NoMethodError: undefined method ‘to_a’ for “ruby on rails”:String

Rubies,
If you are playing with ruby 1.9.2 and trying to invoke .to_a method with string type object but get some error than look the below solution for same.

Suppose we have the string object with value says “ruby on rails” and we want to convert into array by using inbuilt method call ‘.to_a’

ruby-1.9.2-p136 :> “ruby on rails”.to_a
this gives error like
NoMethodError: undefined method `to_a’ for “ruby on rails”:String
so now use
ruby-1.9.2-p136 :> “ruby on rails”.lines.to_a
which gives array of words which splitted by lines
ruby-1.9.2-p136 :> “ruby on rails”.chars.to_a
which gives array of characters

So easy to solve problem?. keep going through my blog and play around rails world.