Problem with listing all documents in a view
aL3xa opened this issue · comments
Recently I had to set up a new development envir on my laptop, and I noticed something strange when I grabbed all my docs from a view. I have this simple model:
class User
include CouchPotato::Persistence
property :first_name, type: String
property :last_name, type: String
property :gender, type: String
view :all, key: :created_at
end
I went and defined a database name, created a new record, and when I grabbed all records from a database, I got this:
> CouchPotato.database.view(User.all)
=> [{"_id"=>"58616c588227552adf1c6e1c68211c54", "_rev"=>"1-93d9fc4a92157d999ac9fe6c53abe2bc", "created_at"=>"2013-03-20T18:32:44Z", "updated_at"=>"2013-03-20T18:32:44Z", "first_name"=>"John", "last_name"=>"Doe", "gender"=>"male", "ruby_class"=>"User"}]
as you can see, it's an array of hashes (or a hash FWIW), and on my previous machine I used to get an array of objects of a given class (User
) in this case. Is this the normal behaviour or does it have anything to do with database setup or something else? All I know is that I'd like to get an array of objects, as I don't want to refactor my code to use []
instead of .
for accessing model instance attributes. =)
Any ideas? Thanks!
Hi, this is the same issue as #80.
Oh, dear. Now that is embarrassing... 😄 The worst part is that I saw the issue, ran the code, and concluded that it's not it... =)