Ruby on Rails Monday, October 3, 2011

On Mon, Oct 3, 2011 at 05:54, sathish kannan <sathitha53384@gmail.com> wrote:

> 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 http://www.ruby-doc.org/core/classes/Hash.html for more info on
hashes.

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

-Dave

--
LOOKING FOR WORK, preferably Ruby on Rails, in NoVa/DC; see main web site.
Main Web Site: davearonson.com
Programming Blog: codosaur.us
Excellence Blog: dare2xl.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment