diff options
| author | Michel Etienne | 2012-08-02 14:57:09 +0200 | 
|---|---|---|
| committer | Michel Etienne | 2012-08-02 14:57:09 +0200 | 
| commit | 90dd53e024748788afdaa06f1075791659f10d7b (patch) | |
| tree | e1f62e25f5812d3ade00a5cf964c0ccf5ac8e355 /app/models/referential.rb | |
| parent | 376d7f3e50ebc9ab8f0be65f6f683a984b839aaf (diff) | |
| download | chouette-core-90dd53e024748788afdaa06f1075791659f10d7b.tar.bz2 | |
check slug values against unvalid postgres constraints
Diffstat (limited to 'app/models/referential.rb')
| -rw-r--r-- | app/models/referential.rb | 14 | 
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb index 068b1df68..ab02930fc 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -8,11 +8,12 @@ class Referential < ActiveRecord::Base    validates_presence_of :lower_corner    validates_uniqueness_of :slug    validates_uniqueness_of :name -  validates_format_of :slug, :with => %r{\A[0-9a-z_]+\Z} +  validates_format_of :slug, :with => %r{\A[a-z][0-9a-z_]+\Z}    validates_format_of :prefix, :with => %r{\A[0-9a-zA-Z_]+\Z}    validates_format_of :upper_corner, :with => %r{\A-?[0-9]+\.?[0-9]*\,-?[0-9]+\.?[0-9]*\Z}    validates_format_of :lower_corner, :with => %r{\A-?[0-9]+\.?[0-9]*\,-?[0-9]+\.?[0-9]*\Z} - +  validate :slug_excluded_values +      attr_accessor :resources    attr_accessor :upper_corner    attr_accessor :lower_corner @@ -20,6 +21,15 @@ class Referential < ActiveRecord::Base    has_many :imports, :dependent => :destroy    has_many :exports, :dependent => :destroy +  def slug_excluded_values +    if slug.start_with? "pg_"  +      errors.add(:slug,"pg_excluded") +    end +    if slug == 'public' +      errors.add(:slug,"public_excluded") +    end +  end +    def human_attribute_name(*args)      self.class.human_attribute_name(*args)    end  | 
