-
-
Save jordanthomas/4264907 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 | |
#Object | |
# by_admin?: true | |
# content: "" | |
# created_at: null | |
# id: null | |
# report_id: 1 | |
# updated_at: null | |
# user_id: 1 | |
# __proto__: Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment