aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-05-13 14:02:08 +0100
committerGareth Rees <gareth@mysociety.org>2015-05-29 14:08:22 +0100
commitdf17b3ccf92ec4097653bb35b594b8e036e88d93 (patch)
tree2e3b80aefcb5fd5c7f32763a2e21c05a811ff51e
parent52eadefd43855f7151792b26790760b161869bea (diff)
Use arel query
-rw-r--r--app/models/public_body.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index fec1cefb6..4e43c890a 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -160,10 +160,11 @@ class PublicBody < ActiveRecord::Base
# like find_by_url_name but also search historic url_name if none found
def self.find_by_url_name_with_historic(name)
- found = PublicBody.find(:all,
- :conditions => ["public_body_translations.url_name=?", name],
- :joins => :translations,
- :readonly => false)
+ found = joins(:translations).
+ where("public_body_translations.url_name = ?", name).
+ readonly(false).
+ all
+
# If many bodies are found (usually because the url_name is the same across
# locales) return any of them
return found.first if found.size >= 1