Sunday, December 4, 2011

Re: [Rails] render partial issue

On Fri, Dec 2, 2011 at 21:56, Moises Luza Ramirez <lists@ruby-forum.com> wrote:

> ActionView::Template::Error (undefined method `each' for #<Payment:
> 0x10a3039e0>):
>   9:          </tr>
>   10:         </thead>
>   11:         <tbody>
>   12:         <% for payment in @payments do %>

It's saying that @payments is a Payment, not an array of them. This
means that your statement:

> @payments =
> Payment.joins(:application_form).where('application_forms.status'
> =>'pending')

is returning a single Payment object. I don't know why it's doing
that -- maybe it's correct behavior in the case of one result, but it
seems to me a one-element array would be "least surprising". As a
workaround you could try immediately after that:

@payments = [@payments] if Payment === @payments

Let us know how that works for you.

Alternately, are you absolutely sure that nothing else is modifying
@payments? Since you have both singular and plural versions, it's
quite plausible that you added an s on some line where you didn't mean
to. Try searching the controller, view, and partials for @payments
and objectively inspecting each occurrence.

-Dave

--
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate