Append the hash error


i want to capture a obj.errors value into a new hash for example

a =
obj.errors = { :a => “can’t be blank” , :b =>“should be alphanumeric”
,:c =>
“Not in the list”}
a << {0 , obj.errors}

it says error like that

undefined method `<<’ for {}:Hash

pls what i miss in this syntax

thanks in advance

On Mon, Oct 3, 2011 at 05:54, sathish kannan [email protected]

a << {0 , obj.errors}

undefined method `<<’ for {}:Hash

pls what i miss in this syntax

What it’s trying to tell you is that the line I quoted above is
syntactically incorrect – that Class Hash does not have a << method.
See for more info on

But to take this a step further, are you sure you want to store it in
a hash, not an array? Arrays do have a << method, and it doesn’t look
to me like you’re storing obj.errors under a really meaningful key.

If you really do want to store obj.errors as the value for key 0, that
would be done as:

a[0] = obj.errors

or if you want to store the zero as a string not a number,

a[‘0’] = obj.errors


LOOKING FOR WORK, preferably Ruby on Rails, in NoVa/DC; see main web
Main Web S.:
Programming Blog:
Excellence Blog: