diff options
author | jessib <jessib@riseup.net> | 2012-10-10 15:52:08 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2012-10-10 15:52:08 -0700 |
commit | cf9ed38ab1840092352efdbb71bfeb5bc3b9f9d5 (patch) | |
tree | 10bfad997861e6a3c49fca3f5c2713d491eff7ee /help/app/controllers | |
parent | 0bdfbdb57ab7c29d0d87dc1a44b17eb32f98439b (diff) |
Some tweaks to get server-side validation working when adding the embedded ticket comment to a new ticket.
Diffstat (limited to 'help/app/controllers')
-rw-r--r-- | help/app/controllers/tickets_controller.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index 2e681b2..be07309 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -4,13 +4,14 @@ class TicketsController < ApplicationController def new @ticket = Ticket.new + @ticket.comments.build end def create @ticket = Ticket.new #:created_by => User.current_test.id @ticket.attributes = params[:ticket]#.except(:comments) @ticket.created_by = User.current_test.id if User.current_test - add_comment + #instead of calling add_comment, we are using comment_attributes= from the Ticket model if @ticket.save respond_with(@ticket) @@ -22,13 +23,14 @@ class TicketsController < ApplicationController def show @ticket = Ticket.find(params[:id]) + # build ticket comments? end def update @ticket = Ticket.find(params[:id]) - add_comment + add_comment #or should we use ticket attributes? @ticket.save - redirect_to @ticket + redirect_to @ticket #difft behavior on failure? end def index @@ -38,6 +40,8 @@ class TicketsController < ApplicationController private + # not using now when creating tickets, we are using comment_attributes= from the Ticket model + #not yet sure about updating tickets def add_comment comment = TicketComment.new(params[:comment]) comment.posted_by = User.current_test.id if User.current_test #could be nil |