diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-05-02 08:13:29 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-05-02 08:13:29 +0100 |
commit | f2367311f662ae5b8da40e59d980b4a6e0726a6b (patch) | |
tree | 14eab91577a5149d04f12d05a7e9c48c2be67092 /app/models/info_request.rb | |
parent | 4533b28661d6ce6973becf5877e82ca5656c37d2 (diff) |
Use routing system to work out URL of request to purge, rather than hard coding it.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 9b129e74b..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") @@ -1046,7 +1049,8 @@ public 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) - req = PurgeRequest.new(:url => "/request/#{self.url_title}", + 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() |