X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ef7f3d800cbdd49b692df10d312e5fd880e2e938..b4caac4d4980dab3e0c94a346a0eac0fa64fbb6f:/app/models/note.rb diff --git a/app/models/note.rb b/app/models/note.rb index f70e4f3bf..31056be49 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -3,12 +3,12 @@ class Note < ActiveRecord::Base has_many :comments, -> { where(:visible => true).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id - validates_presence_of :id, :on => :update - validates_uniqueness_of :id - validates_numericality_of :latitude, :only_integer => true - validates_numericality_of :longitude, :only_integer => true - validates_presence_of :closed_at if :status == "closed" - validates_inclusion_of :status, :in => %w(open closed hidden) + validates :id, :uniqueness => true, :presence => { :on => :update }, + :numericality => { :on => :update, :integer_only => true } + validates :latitude, :longitude, :numericality => { :only_integer => true } + validates :closed_at, :presence => true, :if => proc { :status == "closed" } + validates :status, :inclusion => %w(open closed hidden) + validate :validate_position scope :visible, -> { where("status != 'hidden'") }