undefined method `each'' "ERROR" when using AJAX

Sam Ginko
Thu, 22 Jan 2009 17:09:31 -0000

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: <table width="450" border="0"
cellpadding="0" cellspacing="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
<table width="450" border="0" cellpadding="0"
cellspacing="1" >
  <% @comments.each do |comment|%>



        <table width="100%" border="0"
cellpadding="0" cellspacing="1" >



            <li class=''current-rating''
style=''width:<%= (comment.rating
* 20).to_i -%>px;''>
                  Currently <%= number_with_precision(comment.rating, 1)
%>/5 Stars.









<font
class="txtGraySmall">date posted:
<%comment.created_at.localtime %>




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




  <%end%>



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

page.insert_html :bottom, "rate_div", :partial => "rate",
:object =>
@comments
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---