I have some problems with a very simple Rails configuration using DataMapper. This is my model:
class Capture
include DataMapper::Resource
property :id, Serial
property :identifier, String
property :caption, Text
end
Now I add a new capture in the Rails console:
Capture.create (: identifier => '12345' ,: caption => 'Foo bar foo')
If I try to get all the records
Capture.all
... I get
[#<Capture @id=1 @identifier="12345" @caption=<not loaded>>]
First question: what does “not loaded” mean in this case? But the problem is that I cannot convert the result to JSON:
Capture.all.to_json
NoMethodError: undefined method `encode_json' for #<Capture @id=1 @identifier="12345" @caption=<not loaded>>
Is this a DM problem? How to encapsulate such a result in JSON? Thanks a lot in advance ;-) Chris.
source
share