Skip to content

Instantly share code, notes, and snippets.

@fabiosussetto
Created July 4, 2011 22:42
Show Gist options
  • Save fabiosussetto/1064023 to your computer and use it in GitHub Desktop.
Save fabiosussetto/1064023 to your computer and use it in GitHub Desktop.
#show.js.erb
$('#comments').html('<%= escape_javascript render(@comments) %>');
$('#paginator').html('<%= escape_javascript(paginate(@comments, :remote => true).to_s) %>');
#announces_controller.rb
def show
@announce = Announce.find(params[:id])
@comments = Comment.order("created_at desc").where(:announce_id => @announce.id).includes(:attachments).page(params[:page]).per(10)
@comment = @announce.comments.build
@comment.attachments.build
respond_to do |format|
format.html # show.html.erb
format.js
format.xml { render :xml => @announce }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment