require_dependency "raffle_v1/application_controller" module RaffleV1 class CommentsController < ApplicationController def index @comments = Comment.all respond_to do |format| format.html # index.html.erb format.json { render json: @coments } end end def create @post = Post.find(params[:post_id]) @comment = @post.comments.build(params[:comment]) flash[:notice] = "Comment has been created!" redirect_to post_path end def show @comments = Comment.find(params[:id]) respond_to do |format| format.htmlformat.json { render json: @comment} end end end end