Rails model property persistence problem

93 views
Skip to first unread message

arikan

unread,
Dec 19, 2012, 1:15:37 PM12/19/12
to neo...@googlegroups.com
Hi there, 

Somehow models do not update in rails / neo4j (rails 3.2.8, neo4j 2.2.0), I didn't see such behavior in the previos versions of neo4j.rb.

class User < Neo4j::Rails::Model
  property :email, :type => String, :index => :exact
  property :name, :type => String
  property :view_count, :type => Fixnum, :default => 1
end

user = User.find(1)
=> nil
user.name = "Andreas"
=> "Andreas"
user.save
=> true
=> nil
user.update_attributes(:name => "Andreas")
=> true
=> nil

user.view_count
=> 1
user.view_count = 2
=> 2
user.save
=> true
user.view_count
=> nil

Even though it says true after the save, it returns nil for the updated property. Any idea what might cause this problem?

ps. Also, I used -O flag to skip active record while creating the rails app.

Thanks,
Burak

arikan

unread,
Dec 19, 2012, 1:17:24 PM12/19/12
to neo...@googlegroups.com
the last part should be: 

user.view_count
=> 1
user.view_count = 2
=> 2
user.save
=> true
user.view_count
=> 1

Andreas Ronge

unread,
Dec 19, 2012, 1:40:17 PM12/19/12
to neo...@googlegroups.com
No, I don't know. Is it possible to create a isolated test case for this ?


--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To view this discussion on the web visit https://groups.google.com/d/msg/neo4jrb/-/DC2EtSTu85kJ.

To post to this group, send email to neo...@googlegroups.com.
To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.

arikan

unread,
Dec 19, 2012, 2:56:28 PM12/19/12
to neo...@googlegroups.com
I think this is caused by the Carrierwave (carrierwave-neo4j gem). 

class User < Neo4j::Rails::Model
  property :email, :type => String, :index => :exact
  property :name, :type => String
  property :view_count, :type => Fixnum, :default => 1
  
  mount_uploader :photo, PhotoUploader
end

With Carrierwave's mount_uploader property, User model cannot be updated somehow, but when  mount_uploader is removed update/save functions properly. Wonder how Carrierwave interrupts the updating/saving?

arikan

unread,
Jan 5, 2013, 5:49:43 AM1/5/13
to neo...@googlegroups.com
updated to Neo4j 2.2.3, the Rails model property persistence problem remains. 

Without Carrierwave's mount_uploader property I get the user below:
 
>> user
=> #<User:0x574a5754 @_properties_before_type_cast={}, @_relationships={}, @_properties={"username"=>"arikan", "name"=>"Burak Arikan", "alias"=>nil, "description"=>nil, "image"=>nil, "remote_imageurl"=>nil, "website"=>nil, "location"=>nil, "language"=>nil, "authentication_token"=>nil, "invitation_limit"=>nil, "admin"=>false, "setting_feed_layout"=>0,  "follower_count"=>1, "following_count"=>1, "node_count"=>1, "graph_count"=>1, "created_at"=>1353396304, "updated_at"=>1357381403, "email"=>"ari...@ggg.com", "encrypted_password"=>"$2a$10$MPW9xjyg5AfLqJ8zeDNooeSy8CMEXQtwNcj7CufAou/b/nEb7Mv82", "remember_created_at"=>nil, "reset_password_token"=>nil, "reset_password_sent_at"=>nil, "sign_in_count"=>20, "current_sign_in_at"=>1354821173, "last_sign_in_at"=>1354661996, "current_sign_in_ip"=>"10.0.1.7", "last_sign_in_ip"=>"10.0.1.7", "photo"=>"burak-arikan-2006-compressed.jpg"}, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x367ee335>>

When Carrierwave's  mount_uploader is added to the User model, I got this, and cannot get a result for user.props call.

>> user
#<User:0x7d951dc @_properties_before_type_cast={}, @_properties={"username"=>"arikan", "name"=>"Burak Arikan", "alias"=>nil, "description"=>nil, "image"=>nil, "cover_image"=>nil, "remote_imageurl"=>nil, "website"=>nil, "location"=>nil, "language"=>nil, "authentication_token"=>nil, "invitation_limit"=>nil, "admin"=>false, "photo"=>"burak-arikan-2006-compressed.jpg", "setting_feed_layout"=>0, "follower_count"=>1, "following_count"=>1, "node_count"=>1, "graph_count"=>1, "created_at"=>1353396304, "updated_at"=>1357381403, "email"=>"ari...@ggg.com", "encrypted_password"=>"$2a$10$MPW9xjyg5AfLqJ8zeDNooeSy8CMEXQtwNcj7CufAou/b/nEb7Mv82", "remember_created_at"=>nil, "reset_password_token"=>nil, "reset_password_sent_at"=>nil, "sign_in_count"=>20, "current_sign_in_at"=>1354821173, "last_sign_in_at"=>1354661996, "current_sign_in_ip"=>"10.0.1.7", "last_sign_in_ip"=>"10.0.1.7"}, @_relationships={}, @_mounters={:photo=>#<CarrierWave::Mount::Mounter:0x3468742d @record=#<User:0x7d951dc ...>, @options={}, @uploader=#<PhotoUploader:0x35a3513c @file=#<CarrierWave::SanitizedFile:0x752a55a6 @original_filename=nil, @file="/Users/arikan/Sites/gc/public/uploads/user/photo/1/burak-arikan-2006-compressed.jpg", @content_type=nil>, @model=#<User:0x7d951dc ...>, @versions={:thumb=>#<#<Class:0x6c6fa0b5>:0x14a002b1 @file=#<CarrierWave::SanitizedFile:0x1510bd0b @original_filename=nil, @file="/Users/arikan/Sites/gc/public/uploads/user/photo/1/thumb_burak-arikan-2006-compressed.jpg", @content_type=nil>, @model=#<User:0x7d951dc ...>, @versions={}, @mounted_as=:photo, @storage=#<CarrierWave::Storage::File:0x7deb27fa @uploader=#<#<Class:0x6c6fa0b5>:0x14a002b1 ...>>>}, @mounted_as=:photo, @storage=#<CarrierWave::Storage::File:0x598dceab @uploader=#<PhotoUploader:0x35a3513c ...>>>, @uploader_options={:mount_on=>nil}, @column=:photo>}, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x15dbb76>>

>> user.props

returns nothing, the mount_uploader somehow spoils the model. Any idea, how to approach this problem?

Burak

Andreas Ronge

unread,
Jan 5, 2013, 11:40:47 AM1/5/13
to neo...@googlegroups.com
Hi

The carrierwave-neo4j has not been updated for the last 2 years
(https://github.com/reu/carrierwave-neo4) and all RSpecs failed when I
tried to update.
I did a small modification to neo4j and got it working
(https://github.com/andreasronge/neo4j/commit/a1a22438c2e90d8cfeae26b38c92ad58a1ac8f1f
)

Try with latest neo4j from github and my fork of carrierwave (just
updated the deps):
https://github.com/andreasronge/carrierwave-neo4j

GitHub Issue : https://github.com/andreasronge/neo4j/issues/235


Cheers
Andreas


On Sat, Jan 5, 2013 at 11:49 AM, arikan <ari...@gmail.com> wrote:
> https://groups.google.com/d/msg/neo4jrb/-/xPyTSEI2iKIJ

arikan

unread,
Jan 5, 2013, 12:58:57 PM1/5/13
to neo...@googlegroups.com
Thanks Andreas, 

I installed Carrierwave from your repository, it works in general, but it still does not update a model which has Carrierwave mount_uploader property. Cannot find what causes this problem, any ideas?

class User < Neo4j::Rails::Model
  ...
  mount_uploader :photo, PhotoUploader
end

Burak

Andreas Ronge

unread,
Jan 5, 2013, 2:46:18 PM1/5/13
to neo...@googlegroups.com
I've found where the problem is. I will fix this in the next few days (I hope).
The problem is that the frozen? method has side effects.
(Line 77 in neo4j/lib/neo4j/rails/persistence.rb )
> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/neo4jrb/-/PyKrT9X1iUkJ.

Andreas Ronge

unread,
Jan 5, 2013, 3:07:37 PM1/5/13
to neo...@googlegroups.com

arikan

unread,
Jan 5, 2013, 6:06:27 PM1/5/13
to neo...@googlegroups.com
Andreas thanks a lot! It works quite well.
Reply all
Reply to author
Forward
0 new messages