Hope you have any solution for this

I have a view with two partials:

<!-- LIST -->
<div>
       <p id="ppaypend">
               <%= render :partial => 'list' %>
       </p>
</div>
<!-- FORM -->
<div id="form" style="display: none; ">
       <%= render :partial => 'form' %>
</div>

_list.html.erb partial code is here:

<table>
       <thead>
               <tr>
                       <th>Service</th>
                       <th>percentaje</th>
                       <th>Amount</th>
                       <th>date</th>
                       <th>Select</th>
               </tr>
       </thead>
       <tbody>
       <% for payment in @payments do %>
               <tr>
                       <td><%= payment.service.description %></td>
                       <td><%= payment.service.percentage %></td>
                       <td><%= payment.amount %></td>
                       <td><%= payment.created_at.to_s(:db) %></td>
                       <td><%= link_to 'Select',
edit_payment_path(payment), :remote => true %></td>
               </tr>
       <% end %>
       </tbody>
</table>

the idea of the code is when someone select any item in the table the
form appears to show some information and then the user can update and
submit their changes. After the submit the list need to be updated and
I'm doing it with the following code in the  update.js.erb file

$("#ppaypend").html("<%= escape_javascript( render :partial =>"list" )
%>");

(when i comment this line everything works but obviously the list does
not show the changes)

in my controller i have this to assure the @payments is created every
request:

class PaymentsController < ApplicationController
 before_filter :load

 def load
   @payments =
Payment.joins(:application_form).where('application_forms.status'
=>'pending')
   @payment = Payment.new
 end
 .....
end

the error i have is:

ActionView::Template::Error (undefined method `each' for #<Payment:
0x10a3039e0>):
   9:          </tr>
   10:         </thead>
   11:         <tbody>
   12:         <% for payment in @payments do %>
   13:                 <tr>
   14:                         <td><%= payment.service.description
%></td>
   15:                         <td><%= payment.service.percentage
%></td>
 app/views/payments/_list.html.erb:12:in
`_app_views_payments__list_html_erb__1381777750_2232227020'
 app/views/payments/update.js.erb:3:in
`_app_views_payments_update_js_erb___1521001921_2232244240'
 app/controllers/payments_controller.rb:45:in `update'

-- 
Posted via http://www.ruby-forum.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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to