aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/body_controller.rb
diff options
context:
space:
mode:
authorfrancis <francis>2008-02-27 12:04:10 +0000
committerfrancis <francis>2008-02-27 12:04:10 +0000
commitabc70d713ddbd2e337a0f419a268b964bed66832 (patch)
tree0364cb2a47d4f8b384f4fa1f225a4ac0051edd66 /app/controllers/body_controller.rb
parent6047f78479bb8951b8ce4caab8161767e4ef7646 (diff)
Store URL name in database.
Allow blank short names.
Diffstat (limited to 'app/controllers/body_controller.rb')
-rw-r--r--app/controllers/body_controller.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb
index 7f2d1fe05..a557c0cfc 100644
--- a/app/controllers/body_controller.rb
+++ b/app/controllers/body_controller.rb
@@ -4,27 +4,27 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: body_controller.rb,v 1.4 2008-02-22 13:49:37 francis Exp $
+# $Id: body_controller.rb,v 1.5 2008-02-27 12:04:10 francis Exp $
class BodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
def show
@public_bodies = PublicBody.find(:all,
- :conditions => [ "regexp_replace(replace(lower(short_name), ' ', '-'), '[^a-z0-9_-]', '', 'g') = ?", params[:simple_short_name] ])
+ :conditions => [ "url_name = ?", params[:simple_short_name] ])
if @public_bodies.size > 1
- raise "Two bodies with the same simplified short name: " . params[:simple_short_name]
+ raise "Two bodies with the same URL name: " . params[:simple_short_name]
end
# If none found, then search the history of short names, and do a redirect
if @public_bodies.size == 0
@public_bodies = PublicBody.find(:all,
- :conditions => [ "id in (select public_body_id from public_body_versions where regexp_replace(replace(lower(short_name), ' ', '-'), '[^a-z0-9_-]', '', 'g') = ?)", params[:simple_short_name] ])
+ :conditions => [ "id in (select public_body_id from public_body_versions where url_name = ?)", params[:simple_short_name] ])
if @public_bodies.size > 1
- raise "Two bodies with the same historical simplified short name: " . params[:simple_short_name]
+ raise "Two bodies with the same historical URL name: " . params[:simple_short_name]
end
if @public_bodies.size == 0
raise "None found" # XXX proper 404
end
- redirect_to show_public_body_url(:simple_short_name => simplify_url_part(@public_bodies[0].short_name))
+ redirect_to show_public_body_url(:simple_short_name => @public_bodies[0].url_name)
end
@public_body = @public_bodies[0]
end