diff options
| author | mo k <mo@mokhan.ca> | 2012-06-11 20:56:05 -0600 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-06-11 20:56:05 -0600 |
| commit | ee686cc7845a466abc39baccf298459fa93abfad (patch) | |
| tree | d7ea78f08455f6d9986cb32449f270940832228f /app/controllers/comments_controller.rb | |
| parent | a19f70e8b03edab0e66cfa2d845d9755d9166a0f (diff) | |
| parent | d4a1d71f7d0ce2c3f915b57582b6c1dcb712304f (diff) | |
Merge branch 'master' of bitbucket.org:mocheen/cakeside
Diffstat (limited to 'app/controllers/comments_controller.rb')
| -rw-r--r-- | app/controllers/comments_controller.rb | 16 |
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 |
