diff options
author | Robin Houston <robin@lenny.robin> | 2011-06-15 06:30:45 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-06-15 06:30:45 +0100 |
commit | d9c1cc900f461f58e72939a05b31c374644e0e31 (patch) | |
tree | 12c5846fcd0a074bc37e69cdc8f64b462f3f3c74 | |
parent | f0780e6ba398f0febac537a15ada6c25d0bd1f5e (diff) |
Set the default value for publication_scheme explicitly in an after_initialize callback, because the usual mechanism for setting default values (whatever that is) does not seem to work with attributes that are translated by the globalize2 plugin
-rw-r--r-- | app/models/public_body.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 41bafa718..d5538fb6e 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -46,6 +46,12 @@ class PublicBody < ActiveRecord::Base translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme + # Make sure publication_scheme gets the correct default value. + # (This would work automatically, were publication_scheme not a translated attribute) + def after_initialize + self.publication_scheme = "" if self.publication_scheme.nil? + end + # 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_by_url_name(name) |