summaryrefslogtreecommitdiff
path: root/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/comments_controller.rb')
-rw-r--r--app/controllers/comments_controller.rb18
1 files changed, 18 insertions, 0 deletions
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