Permalink
Browse files

Try to get carrierwave-neo4j working with neo4j, #235

  • Loading branch information...
1 parent 43b3362 commit a1a22438c2e90d8cfeae26b38c92ad58a1ac8f1f @andreasronge andreasronge committed Jan 5, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/neo4j/rails/attributes.rb
@@ -85,7 +85,7 @@ def attributes=(attributes, guard_protected_attributes = true)
end
def attribute_defaults
- self.class.attribute_defaults
+ self.class.attribute_defaults || {}
end
# Updates this resource with all the attributes from the passed-in Hash and requests that the record be saved.
@@ -231,6 +231,9 @@ def read_attribute(key)
if @_properties.has_key?(key)
@_properties[key]
else
+ #puts "@_properties #{@_properties}"
+ #puts "attribute_defaults #{attribute_defaults.inspect}"
+ #puts "Key #{key}, self #{self}"
@_properties[key] = (!new_record? && _java_entity.has_property?(key)) ? read_property_from_db(key) : attribute_defaults[key]
end
end
@@ -378,7 +381,7 @@ def _classname
# Ensure any defaults are stored in the DB
def write_default_attributes
- self.class.attribute_defaults.each do |attribute, value|
+ self.attribute_defaults.each do |attribute, value|
write_property_from_db(attribute, Neo4j::TypeConverters.convert(value, attribute, self.class, false)) unless changed_attributes.has_key?(attribute) || _java_entity.has_property?(attribute)
end
end

0 comments on commit a1a2243

Please sign in to comment.