Created
December 12, 2012 04:23
-
-
Save anonymous/4264846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
respond_to :html, :json | |
def create | |
@report = Report.find(params[:report_id]) | |
@comment = @report.comments.build(params[:comment]) | |
@comment.user = current_user | |
respond_with @report, @comment, :methods => [:by_admin?] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for [@report, @report.comments.build], :remote => true, :html => {:'data-type' => 'json'} do |f| %> | |
<%= f.text_area :content, :rows => '3', :placeholder => 'Type your comment here.' %> | |
<%= f.submit %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on 'ajax:success', '#new_comment', (e, data, status, xhr) -> | |
console.log data | |
# logs @comment as json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment