- validates_inclusion_of :status, :in => [ "open", "closed", "hidden" ]
-
-
- def self.create_bug(lat, lon, comment)
- bug = MapBug.new(:lat => lat, :lon => lon);
- raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
- bug.text = comment
- bug.date_created = Time.now.getutc
- bug.last_changed = Time.now.getutc
- bug.status = "open";
- bug.save;
- return bug;
+ validates_presence_of :date_closed if :status == "closed"
+ validates_inclusion_of :status, :in => ["open", "closed", "hidden"]
+
+ def self.create_bug(lat, lon)
+ bug = MapBug.new(:lat => lat, :lon => lon)
+ raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world?
+
+ bug.date_created = Time.now.getutc
+ bug.last_changed = Time.now.getutc
+ bug.status = "open"
+
+ return bug