From f2367311f662ae5b8da40e59d980b4a6e0726a6b Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 2 May 2012 08:13:29 +0100 Subject: Use routing system to work out URL of request to purge, rather than hard coding it. --- app/models/info_request.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/models/info_request.rb') 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() -- cgit v1.2.3