diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/comment_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 5 |
2 files changed, 16 insertions, 12 deletions
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index 8ac6d3850..ff49b2a79 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: comment_controller.rb,v 1.5 2008-08-29 12:03:40 francis Exp $ +# $Id: comment_controller.rb,v 1.6 2008-09-02 14:57:31 francis Exp $ class CommentController < ApplicationController @@ -12,19 +12,26 @@ class CommentController < ApplicationController if params[:type] == 'request' @info_request = InfoRequest.find_by_url_title(params[:url_title]) @track_thing = TrackThing.create_track_for_request(@info_request) - @comment = Comment.new(params[:comment].merge({ - :comment_type => 'request', - :user => @user - })) + if params[:comment] + @comment = Comment.new(params[:comment].merge({ + :comment_type => 'request', + :user => @user + })) + end else raise "Unknown type " + params[:type] end - # XXX this check should theoretically be a validation rule in the model - @existing_comment = Comment.find_by_existing_comment(@info_request.id, params[:comment][:body]) + if params[:comment] + # XXX this check should theoretically be a validation rule in the model + @existing_comment = Comment.find_by_existing_comment(@info_request.id, params[:comment][:body]) + else + # Default to subscribing to request when first viewing form + params[:subscribe_to_request] = true + end # See if values were valid or not - if !@existing_comment.nil? || !@comment.valid? || params[:reedit] + if !params[:comment] || !@existing_comment.nil? || !@comment.valid? || params[:reedit] render :action => 'new' return end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 19a602571..ac025b94a 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.102 2008-08-31 23:43:52 francis Exp $ +# $Id: request_controller.rb,v 1.103 2008-09-02 14:57:31 francis Exp $ class RequestController < ApplicationController @@ -39,9 +39,6 @@ class RequestController < ApplicationController # Track corresponding to this page @track_thing = TrackThing.create_track_for_request(@info_request) @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ] - - # Default to subscribing to requests - params[:subscribe_to_request] = true end # Requests similar to this one |