diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-03-11 14:33:51 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-03-13 11:48:42 +0000 |
commit | ec925323afce0e2f2c3dbca0b3a1efb054d468e6 (patch) | |
tree | f0788a27ee897f28020d7ef1b8fcaaa6484ae486 /app/controllers/comment_controller.rb | |
parent | 10fbde73f2782df0f007c668d07c8067b2fbb4dc (diff) |
Extract create_track_thing from CommentController
Use a before_filter to make @track_thing available to all filters
called on the same action and remove responsibility from the #new method
Diffstat (limited to 'app/controllers/comment_controller.rb')
-rw-r--r-- | app/controllers/comment_controller.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index c2315b73e..18544a98f 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -7,10 +7,10 @@ class CommentController < ApplicationController before_filter :check_read_only, :only => [ :new ] before_filter :find_info_request, :only => [ :new ] + before_filter :create_track_thing, :only => [ :new ] protect_from_forgery :only => [ :new ] def new - @track_thing = TrackThing.create_track_for_request(@info_request) if params[:comment] @comment = Comment.new(params[:comment].merge({ :comment_type => 'request', @@ -100,4 +100,8 @@ class CommentController < ApplicationController end end + def create_track_thing + @track_thing = TrackThing.create_track_for_request(@info_request) + end + end |