diff options
Diffstat (limited to 'app/models/public_body.rb')
-rw-r--r-- | app/models/public_body.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index bc8f084bb..fb30da234 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,5 +1,5 @@ +# -*- coding: utf-8 -*- # == Schema Information -# Schema version: 114 # # Table name: public_bodies # @@ -19,7 +19,6 @@ # publication_scheme :text default(""), not null # api_key :string(255) not null # - # models/public_body.rb: # A public body, from which information can be requested. # @@ -43,6 +42,7 @@ class PublicBody < ActiveRecord::Base has_many :info_requests, :order => 'created_at desc' has_many :track_things, :order => 'created_at desc' + has_many :censor_rules, :order => 'created_at desc' has_tag_string @@ -93,8 +93,9 @@ class PublicBody < ActiveRecord::Base # Make sure publication_scheme gets the correct default value. # (This would work automatically, were publication_scheme not a translated attribute) self.publication_scheme = "" if self.publication_scheme.nil? - - # Set an API key if there isn’t one + end + + def before_save self.api_key = SecureRandom.base64(33) if self.api_key.nil? end @@ -103,7 +104,7 @@ class PublicBody < ActiveRecord::Base locale = self.locale || I18n.locale PublicBody.with_locale(locale) do found = PublicBody.find(:all, - :conditions => ["public_body_translations.url_name='#{name}'"], + :conditions => ["public_body_translations.url_name=?", name], :joins => :translations, :readonly => false) # If many bodies are found (usually because the url_name is the same across @@ -583,5 +584,3 @@ class PublicBody < ActiveRecord::Base end end - - |