CIMI: Replace save! with save in datamapper
For unknown reason the 'save!' method does not
work properly when using 'dm-timestamps'.
However there is no reason to use exlamation mark
suffix anyway.
diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
index 22d20ac..ac6ae4f 100644
--- a/server/lib/cimi/helpers/database_helper.rb
+++ b/server/lib/cimi/helpers/database_helper.rb
@@ -48,6 +48,7 @@
def store_attributes_for(model, attrs={})
return if test_environment? or model.nil? or attrs.empty?
+ return if model.id.nil?
entity = get_entity(model) || current_db.entities.new(:be_kind => model.to_entity, :be_id => model.id)
entity.description = extract_attribute_value('description', attrs) if attrs.has_key? 'description'
@@ -58,7 +59,7 @@
entity.ent_properties = extract_attribute_value('property', attrs).to_json
end
- entity.save! && entity
+ entity.save && entity
end
# In XML serialization the values stored in attrs are arrays, dues to
diff --git a/server/lib/cimi/models/address_template.rb b/server/lib/cimi/models/address_template.rb
index c8a4de6..2d81f23 100644
--- a/server/lib/cimi/models/address_template.rb
+++ b/server/lib/cimi/models/address_template.rb
@@ -78,7 +78,7 @@
:be_kind => 'address_template',
:be_id => ''
)
- new_template.save!
+ new_template.save
from_db(new_template, context)
end
@@ -99,7 +99,7 @@
:be_kind => 'machine_template',
:be_id => ''
)
- new_template.save!
+ new_template.save
from_db(new_template, context)
end
diff --git a/server/lib/cimi/models/machine_template.rb b/server/lib/cimi/models/machine_template.rb
index 4fb8cd5..eb660d2 100644
--- a/server/lib/cimi/models/machine_template.rb
+++ b/server/lib/cimi/models/machine_template.rb
@@ -70,7 +70,7 @@
:be_kind => 'machine_template',
:be_id => ''
)
- new_template.save!
+ new_template.save
from_db(new_template, context)
end
@@ -85,7 +85,7 @@
:be_kind => 'machine_template',
:be_id => ''
)
- new_template.save!
+ new_template.save
from_db(new_template, context)
end
diff --git a/server/lib/cimi/models/volume_configuration.rb b/server/lib/cimi/models/volume_configuration.rb
index 4a8373e..b0ba85b 100644
--- a/server/lib/cimi/models/volume_configuration.rb
+++ b/server/lib/cimi/models/volume_configuration.rb
@@ -36,7 +36,7 @@
:be_kind => 'volume_configuration',
:be_id => ''
)
- new_config.save!
+ new_config.save
from_db(new_config, context)
end
@@ -52,7 +52,7 @@
:be_kind => 'volume_configuration',
:be_id => ''
)
- new_config.save!
+ new_config.save
from_db(new_config, context)
end
diff --git a/server/lib/cimi/models/volume_template.rb b/server/lib/cimi/models/volume_template.rb
index f40a300..a2b8eb7 100644
--- a/server/lib/cimi/models/volume_template.rb
+++ b/server/lib/cimi/models/volume_template.rb
@@ -67,7 +67,7 @@
:be_kind => 'volume_template',
:be_id => ''
)
- new_template.save!
+ new_template.save
from_db(new_template, context)
end