diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-05-03 18:57:51 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-05-03 18:57:51 +0100 |
commit | 20324887036cccc940e1d68fe8c99864b5b634bd (patch) | |
tree | e8968ddf336b65d40d295421d19091f061d940ca /app/models/info_request.rb | |
parent | c86325840e2204daea36e68fac045a215a26eafe (diff) | |
parent | 858898510fe77550ac6550a6b306b5c7a2b93d31 (diff) |
Merge branch 'develop' of github.com:sebbacon/alaveteli into develop
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index b5a1cd833..78121f5ea 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -23,6 +23,9 @@ require 'digest/sha1' class InfoRequest < ActiveRecord::Base + include ActionView::Helpers::UrlHelper + include ActionController::UrlWriter + strip_attributes! validates_presence_of :title, :message => N_("Please enter a summary of your request") @@ -453,7 +456,6 @@ public # An annotation (comment) is made def add_comment(body, user) comment = Comment.new - ActiveRecord::Base.transaction do comment.body = body comment.user = user @@ -1042,6 +1044,18 @@ public end return ret end + + before_save :purge_in_cache + def purge_in_cache + if !MySociety::Config.get('VARNISH_HOST').nil? && !self.id.nil? + # we only do this for existing info_requests (new ones have a nil id) + path = url_for(:controller => 'request', :action => 'show', :url_title => self.url_title, :only_path => true, :locale => :none) + req = PurgeRequest.new(:url => path, + :model => self.class.base_class.to_s, + :model_id => self.id) + req.save() + end + end end |