aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application.rb4
-rw-r--r--app/controllers/body_controller.rb5
-rw-r--r--app/controllers/user_controller.rb4
3 files changed, 8 insertions, 5 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 1410aff29..1fde074a9 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.18 2007-10-31 12:14:20 francis Exp $
+# $Id: application.rb,v 1.19 2007-10-31 12:39:58 francis Exp $
class ApplicationController < ActionController::Base
@@ -142,7 +142,7 @@ class ApplicationController < ActionController::Base
# Simplified links to our objects
# XXX See controllers/user_controller.rb controllers/body_controller.rb for inverse
# XXX consolidate somehow with stuff in helpers/application_helper.rb
- # use :helper_method => :your_method_name
+ helper_method :simplify_url_part
def simplify_url_part(text)
text.downcase!
text.gsub!(/ /, "-")
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb
index 0a267118a..ba90f317f 100644
--- a/app/controllers/body_controller.rb
+++ b/app/controllers/body_controller.rb
@@ -4,7 +4,7 @@
# 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.2 2007-10-30 18:52:27 francis Exp $
+# $Id: body_controller.rb,v 1.3 2007-10-31 12:39:58 francis Exp $
class BodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
@@ -21,6 +21,9 @@ class BodyController < ApplicationController
if @public_bodies.size > 1
raise "Two bodies with the same historical simplified short 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))
end
@public_body = @public_bodies[0]
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index a0ac68443..959630166 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -4,10 +4,10 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user_controller.rb,v 1.5 2007-10-30 17:31:31 francis Exp $
+# $Id: user_controller.rb,v 1.6 2007-10-31 12:39:58 francis Exp $
class UserController < ApplicationController
- # XXX See helpers/application_helper.rb simplify_url_part fo reverse of expression in SQL below
+ # XXX See controllers/application.rb simplify_url_part for reverse of expression in SQL below
def show
@display_users = User.find(:all, :conditions => [ "regexp_replace(replace(lower(name), ' ', '-'), '[^a-z0-9_-]', '', 'g') = ?", params[:simple_name] ], :order => "created_at desc")
end