Hi all.
I’m doing my own blog-like site, so I’ve an Post controller and an
Comments
controller and I want to ajaxify my comments form. So, I’ve did the
following:
[comments_controller.rb]
class CommentsController < ResourceController::Base
belongs_to :post, :article, :photo
create do
flash “Comment posted successfuly”
wants.html { redirect_to :back }
wants.js { render :layout => false }
end
end
[/comments_controller.rb]
[create.js.rjs]
page.replace_html(“comments”, :partial => “comment”, :collection =>
@post.comments)
[/create.js.rjs]
[views/posts/show.html.erb]
<%= render :partial => “post”, :object => @post %>
Comments
<% remote_form_for([@post,Comment.new], :update => “new_comment”) do |f|
%>
<%= render :partial => “comments/form”, :locals => { :f => f } %>
<%= submit_tag "Create" %>
<% end %> [/views/posts/show.html.erb]Please, also note that I’m using resource_controller plugin.
When I write down my comment, comments_partial is updated and my new
comment
appears, but I also got the following:
[output]
Element.update(“comments”, “\u003Ca
href="http://presto.stellar.com.br"\u003Edavi\u003C/a\u003E said, in
Post
Fouth post at\nSun Jun 15 12:04:33 -0300
2008:\u003Cbr/\u003E\nCommenting!
I’m enjoying Rails!!! Finaly!! =D\n\u003Cbr/\u003E\u003Cbr/\u003E\u003Ca
href="http://presto.stellar.com.br"\u003Edavi\u003C/a\u003E said, in
Post
Fouth post at\nSun Jun 15 12:05:25 -0300 2008:\u003Cbr/\u003E\nI’ve
learned
how to restart Passenger… =)\n\u003Cbr/\u003E\u003Cbr/\u003E\u003Ca
href="http://my.coolsite.com"\u003Eauthor\u003C/a\u003E said, in Post
Fouth
post at\nMon Jun 16 00:50:43 -0300 2008:\u003Cbr/\u003E\nmy
comment\n\u003Cbr/\u003E\u003Cbr/\u003E”);
[/output]
and my comments’ form desapair.
What am I missing here?
Please, sorry for my very bad English.
Best regards,
Davi V.
E-mail: [email protected]
MSN : [email protected]
GTalk : [email protected]
Skype : davi vidal
YIM : davi_vidal
ICQ : 138815296