Ok, I figured out a workaround for this.
In my model Foo
, I added the following method:
def label
name
end
And then I changed the to_json
options as thus:
Foo.all.to_json(:methods => :label)
and got the results I wanted. Actually, to make things work even more smoothly, I ended up narrowing down the DataMapper query some more:
Foo.all(:fields => [:name]).to_json(:methods => :label, :only => :label)