Here's the flow I have...
First, jquery posts the new comment to the server:
$.post(this.action,$(this).serialize(),null,'script');
Then in the comments controller:
def create
@comment = lots of stuff going on here but it works...
if @comment.save
flash[:notice] = "Successfully created comment."
respond_to do |format|
format.js
end
end
Ok and this is where I'm stuck, then the create.js.erb:
$(".cmtBox").html("<%=escape_javascript(render :partial =>"comments/comment")%>");
And the partial:
<div class="cmtBox" id="comment_<%=comment.id%>">
<%=comment.content%>
</div>
Where I'm stuck is calling the partial in create.js.erb... How do I pass what Rails needs to populate the partial? Right now I get the error: "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id"
Thanks!