I've some trouble with a really simple Rails setup 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 Rails console by:
Capture.create(:identifier => '12345', :caption => 'Foo bar foo')
If I try to get all captures by
Capture.all
... i get a
[#<Capture @id=1 @identifier="12345" @caption=<not loaded>>]
First question: what does the "not loaded" mean in this case? But the trouble I have is 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 it a DM issue? How to encapsulate such a result into JSON? Many thanks in advance ;-) Chris.