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: <tr>
4: <td>
5: <div style="padding-bottom:10px;">
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
<div id="rate_div">
<%= render(:partial => "rate", :object => @comments) %>
</div>
######### partial code
<table width="450" border="0" cellpadding="0" cellspacing="1" >
<% @comments.each do |comment|%>
<tr>
<td>
<div style="padding-bottom:10px;">
<table width="100%" border="0" cellpadding="0" cellspacing="1" >
<tr>
<td>
<ul class='star-rating'>
<li class='current-rating' style='width:<%= (comment.rating
* 20).to_i -%>px;'>
Currently <%= number_with_precision(comment.rating, 1)
%>/5 Stars.<br><br>
</li>
<li>
<li class='one-star'></li>
<li class='two-stars'></li>
<li class='three-stars'></li>
<li class='four-stars'></li>
<li class='five-stars'></li>
</ul>
</td>
<td align=right class="txtBlackSmall"><font
class="txtGraySmall"><i>date posted:</i></font> <%=
comment.created_at.localtime %></td>
</tr>
</table>
</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%></div>
</td>
</tr>
<%end%>
</table>
########## 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 [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
-~----------~----~----~----~------~----~------~--~---