set_table_name 'current_ways'
def self.from_xml(xml, create=false)
set_table_name 'current_ways'
def self.from_xml(xml, create=false)
- pt.find('tag').each do |tag|
- way.add_tag_keyval(tag['k'], tag['v'])
- end
+ pt.find('tag').each do |tag|
+ way.add_tag_keyval(tag['k'], tag['v'])
+ end
# use the cache if available
elsif self.user.data_public?
user_display_name_cache[self.user_id] = self.user.display_name
# use the cache if available
elsif self.user.data_public?
user_display_name_cache[self.user_id] = self.user.display_name
- t = Time.now
- self.timestamp = t
- self.save
-
- WayTag.delete_all(['id = ?', self.id])
-
- self.tags.each do |k,v|
- tag = WayTag.new
- tag.k = k
- tag.v = v
- tag.id = self.id
- tag.save
- end
+ begin
+ Way.transaction do
+ t = Time.now
+ self.timestamp = t
+ self.save!
+
+ tags = self.tags
+
+ WayTag.delete_all(['id = ?', self.id])
+
+ tags.each do |k,v|
+ tag = WayTag.new
+ tag.k = k
+ tag.v = v
+ tag.id = self.id
+ tag.save!
+ end