Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Rails: Partial Rendering with Ajax not working - Commenting System Like FB
  2. class CommentsController < ApplicationController
  3.   def create
  4.     @micropost = Micropost.find(params[:micropost_id])
  5.     @comment = @micropost.comments.build(params[:comment])
  6.     @comment.user_id = current_user.id
  7.     @comment.save
  8.       respond_to do |format|
  9.       format.html
  10.       format.js
  11.     end
  12.   end
  13. end
  14.        
  15. <div id='CommentContainer-<%= micropost.id%>' class='CommentContainer Condensed2'>
  16. <div class='Comment'>
  17. <%= render :partial => "comments/form", :locals => { :micropost => micropost } %>
  18. </div>
  19. <div id='comments'>
  20. <%=render micropost.comments %>
  21. </div>
  22. </div>