diff options
Diffstat (limited to 'app/controllers/file_request_controller.rb')
-rw-r--r-- | app/controllers/file_request_controller.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/app/controllers/file_request_controller.rb b/app/controllers/file_request_controller.rb index d9f22d804..ab9390a4f 100644 --- a/app/controllers/file_request_controller.rb +++ b/app/controllers/file_request_controller.rb @@ -4,31 +4,32 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: file_request_controller.rb,v 1.7 2007-09-11 15:21:30 francis Exp $ +# $Id: file_request_controller.rb,v 1.8 2007-09-12 15:56:18 francis Exp $ class FileRequestController < ApplicationController def index + # render index.rhtml template end +# before_filter :check_authentication, :only => [:create] def create + # Create both FOI request and the first request message @info_request = InfoRequest.new(params[:info_request]) @outgoing_message = OutgoingMessage.new(params[:outgoing_message].merge({ :status => 'ready', :message_type => 'initial_request' })) + @outgoing_message.info_request = @info_request # Save both models - ActiveRecord::Base.transaction do - begin - @info_request.save! - @outgoing_message.info_request_id = @info_request.id - @outgoing_message.save! - # render create action - rescue ActiveRecord::RecordInvalid => e - @outgoing_message.valid? # force cecking of errors even if info_request fails - render :action => 'index' - end + valid = @info_request.valid? + valid &&= @outgoing_message.valid? # XXX maybe there is a nicer way of preventing lazy boolean evaluation than this + if valid + @info_request.save! + @outgoing_message.save! + else + render :action => 'index' end end |