summaryrefslogtreecommitdiff
path: root/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-06-07 22:23:58 -0600
committermo k <mo@mokhan.ca>2012-06-07 22:23:58 -0600
commitdc05d508ccac71000f552435bab97bd8ba697bae (patch)
tree456e81edc46c071713055f6f1603a6981f79b4f9 /app/controllers/comments_controller.rb
parentc4aecda657b45842fac124e1f1f31a62bf754a5d (diff)
create comment controller and add form to creation#show page.
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