From dc05d508ccac71000f552435bab97bd8ba697bae Mon Sep 17 00:00:00 2001 From: mo k Date: Thu, 7 Jun 2012 22:23:58 -0600 Subject: create comment controller and add form to creation#show page. --- app/controllers/comments_controller.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/controllers/comments_controller.rb (limited to 'app/controllers/comments_controller.rb') diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 00000000..b1e2b7fe --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,18 @@ +class CommentsController < ApplicationController + before_filter :authenticate_user! + + def new + @comment = Comment.new + end + + def create + creation = Creation.find(params[:creation_id]) + comment = Comment.build_from(creation, current_user, params[:comment][:body]) + if comment.save + redirect_to creation_path(creation) + else + flash[:error] = "Ooops... we couldn't save your comment at this time." + render 'new' + end + end +end -- cgit v1.2.3