I''m listing comments within a div, id="comments". Whenever a
new
comment is added, the list is supposed to update with all of the
comments for a given element.
*The problem is* that the div updates with the comment I''ve entered
followed by all of the comments that were already listed, _except_ for
the first one. So if I enter a new comment I''ll get the list of
comments which were already attached to the element, followed by the
comment I''ve entered, followed by the list of comments again with the
exception of the very first comment in this list. Argh!
This is an intermittent error, but I''m not doing anything funky with
sessions or caching or anything, really and truly.
Very, very strange. It _seems_ as if I''ve got the correct code that
should do this properly:
Relevant controller code:
----------
@comments = Comment.find(:all, :conditions => ["element_id =
?",
@element.id], :order => ''created_at'' )
View:
----------
<!-- comments -->
<div id="comments">
<%= render :partial => ''comment'' %>
</div>
Partial (the whole enchilada here):
----------
<p style="margin: 20px 0 -10px 0; font-style:
italic">Comments</p>
<% for comment in @comments -%>
<% @comment = comment %>
<p class="comment_source"><%= @comment.account.login %>
says:</p>
<% if @admin or (not @session[''account''].nil? and
comment.account_id
== @session[''account''].id) -%>
<p class="comment_delete_button right"><%= link_to_remote
"delete", :url => { :controller => ''site'',
:action =>
''delete_comment'', :id => @comment.id }, :confirm =>
''Are you sure you
wish to delete this comment?'' %></p>
<%= in_place_field ''Comment'', @comment,
''body'', nil, { :class =>
''comment'', :cols => 50, :rows => 5 } %>
<% else -%>
<span class="comment"><%= textilize_without_paragraph
comment.body
%></span>
<% end -%>
<% end -%>
RJS:
----------
page[:comments].replace_html :partial => ''comment''
page[:comment_form].replace_html :partial => ''new_comment''
Any help or insights would be very, very, very much appreciated.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---