Undefined method `each' "ERROR" when using AJAX


#1

I’m trying to update a set of comments in my app. I’m trying to use ajax
to do so and I’m running into problems. I’m getting the error below

undefined method `each’ for #Ratecomment:0x267ac80
Extracted source (around line #2):

1:


2: <% @comments.each do |comment|%>
3:
4:

5:

Hope someone can help.

######### controller code

def rate_new

@furni = Furni.find(params[:id])
@comments = Ratecomment.new(params[:ratecomment])
if @comments.save
  Rating.delete_all(["rateable_type = 'Furni' AND rateable_id = ?",

@furnii])
@furni.add_rating Rating.new(:rating =>
params[:ratecomment][“rating”])
@comments.save!
else
flash[:notice] = ‘Comment field can not be empty!’
end

end

######### view code


<%= render(:partial => “rate”, :object => @comments) %>

######### partial code

<% @comments.each do |comment|%> <%end%>
  • Currently <%= number_with_precision(comment.rating, 1) %>/5 Stars.

date posted: <%= comment.created_at.localtime %>
  </div>
  <div style="padding-bottom:10px; border-style:solid;

border-bottom-width:1px; border-left-width:0px; border-right-width:0px;
border-top-width:0px; border-color:#cccccc; "><%=comment.content%>

</td>

########## content in the rate_new.rjs

page.insert_html :bottom, “rate_div”, :partial => “rate”, :object =>
@comments


#2

Sam G. wrote: CORRECTION ON THE RJS file
the content reads:

page.replace_html “rate_div”, :partial => “rate”, :object => @comments