Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CouchPotato.database.load_document does not instantiate the correct class #109

Closed
pawurb opened this issue May 8, 2015 · 6 comments
Closed

Comments

@pawurb
Copy link

pawurb commented May 8, 2015

Hello. I execute the following commands:

CouchPotato::Config.database_name = 'couch_db_name'
user = User.new(_id: 'uniq_id', name: 'test_user')
CouchPotato.database.save_document user
result = CouchPotato.database.load_document(user._id)
result.class => CouchRest::Document

According to the docs the result object should be of class User (the one that includes CouchPotato::Persistence module). I am new to non relational databases. Please let me know if I am doing something wrong.

@langalex
Copy link
Owner

langalex commented May 9, 2015

what does your user class look like?

converting JSON back to ruby classes is actually done by the json gem. maybe some other gem is messing with that. can you check what JSON.create_id returns? should be 'ruby_class'.

@pawurb
Copy link
Author

pawurb commented May 9, 2015

JSON.create_id returns a "ruby_class" string. My User class looks like this:

class User
  include CouchPotato::Persistence

  property :name
end

@langalex
Copy link
Owner

langalex commented May 9, 2015

Sorry I'm not really sure how to help you. Can you post your entire/simplified code in a gist or so so I can reproduce the problem?

@pawurb
Copy link
Author

pawurb commented May 9, 2015

Please check out this barebones rails project repo with only couch_potato gem and User class added https://github.com/pawurb/couch_potato_issue. You can replicate my issue with the following commands:

CouchPotato::Config.database_name = 'test'
u = User.new(_id: 'uniq_id', name: 'test_user')
CouchPotato.database.save_document u
result = CouchPotato.database.load_document 'uniq_id'
result.class => CouchRest::Document

I will be greatful for any clue on that.

@langalex
Copy link
Owner

you are using version 0.7.1, the current version is 1.4.0

@pawurb
Copy link
Author

pawurb commented May 11, 2015

That explains a lot. Thanks !

@pawurb pawurb closed this as completed May 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants