1 class MapBug < ActiveRecord::Base
4 set_table_name 'map_bugs'
6 validates_presence_of :id, :on => :update
7 validates_uniqueness_of :id
8 validates_numericality_of :latitude, :only_integer => true
9 validates_numericality_of :longitude, :only_integer => true
10 validates_presence_of :date_created
11 validates_presence_of :last_changed
12 validates_inclusion_of :status, :in => [ "open", "closed", "hidden" ]
14 has_many :map_bug_comment, :foreign_key => :bug_id, :order => :date_created, :conditions => { :visible => true }
17 def self.create_bug(lat, lon)
18 bug = MapBug.new(:lat => lat, :lon => lon);
19 raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
20 bug.date_created = Time.now.getutc
21 bug.last_changed = Time.now.getutc
27 self.status = "closed"
28 self.last_changed = Time.now.getutc