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.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