undefined method `each' for "":String

I implemented creating an object within another object according to
this Railscast:


but I'm getting this error after I submit. Any ideas?

undefined method `each' for "":String

I didn't look at the code but it appears you are trying to iterate over
an empty string.

I think you may need to show us the code around the error.


I'm guessing that you are using Ruby 1.9, Ruby 1.8 had a String#each
method, Ruby 1.9 does not, you need to use each_line instead.

Sounds like you have hit the same one I did:


As it turns out, I had declared that my main object class had many of
another type of object (photos). In my object controller new method I


But then in my form I only had one field for the photo object. It was
trying to build the photo objects with just one string as input and
that is what was giving the method 'each' error for String.