summaryrefslogtreecommitdiff
path: root/app/controllers/comments_controller.rb
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-06-11 20:56:05 -0600
committermo k <mo@mokhan.ca>2012-06-11 20:56:05 -0600
commitee686cc7845a466abc39baccf298459fa93abfad (patch)
treed7ea78f08455f6d9986cb32449f270940832228f /app/controllers/comments_controller.rb
parenta19f70e8b03edab0e66cfa2d845d9755d9166a0f (diff)
parentd4a1d71f7d0ce2c3f915b57582b6c1dcb712304f (diff)
Merge branch 'master' of bitbucket.org:mocheen/cakeside
Diffstat (limited to 'app/controllers/comments_controller.rb')
-rw-r--r--app/controllers/comments_controller.rb16
1 files changed, 7 insertions, 9 deletions
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 4848c972..6ea6f0b1 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -6,14 +6,12 @@ class CommentsController < ApplicationController
end
def create
- creation = Creation.find(params[:creation_id])
- comment = Comment.build_from(creation, current_user.id, params[:comment][:body])
- if comment.save
- flash[:notice] = "Your comment was added!"
- redirect_to creation_path(creation)
- else
- flash[:error] = "Ooops... we couldn't save your comment at this time."
- render 'new'
- end
+ command_for(CommentOnCreationCommand).run(params)
+ flash[:notice] = params[:comment][:body]
+ redirect_to :controller => 'creations', :action => 'show', :id => params[:creation_id]
+ end
+
+ def command_for(command)
+ command.new(current_user)
end
end