to_hash result for photo cannot be saved in mongoid
Closed this issue · 1 comments
sufleR commented
When I try to save hash representation of returned photo I get error:
photo = flickr.photos.getInfo(photo_id: photo_id, secret: secret)
photo_hash= photo.to_hash
photo_hash_.class
=> Hash
photo_hash.class.class
=> Class
photo_hash.to_bson
#NoMethodError: undefined method `bson_type' for #<FlickRaw::Response:0x0000010d4ab9c0>
#from ....gems/ruby-2.1.1@..../gems/bson-2.3.0/lib/bson/hash.rb:44:in `block (2 levels) in to_bson'
posiible workaround for this:
JSON.parse(photo.to_json).to_bson
#bson result.
Is there any other solution to save this hash in mongodb properly?
hanklords commented
The Flickraw objects don't have the bson serialization methods so you have to add them yourself.