I've started to use Datamapper with Padrino and i have some weird issue. The issues is explained below:
1.The code:
content_type :json
@fonts = Font.all(:fields=>[:id,:name,:class_name])
@fonts.to_json
Please see the sql queries that executed:
DEBUG - (0.000087) SELECT id
, name
, class_name
FROM fonts
ORDER BY id
DEBUG - (0.000205) SELECT id
, post_script_name
, designer
, license
, category
, full_name
, style
, weight
, filename
, copyright
, system_file_path
, http_path
, ext
FROM fonts
ORDER BY id
DEBUG - (0.000158) SELECT id
, font_face
FROM fonts
ORDER BY id
Please help me with that Why it's happening ?
Thank you in advance!
The solution is:
content_type :json
fields_to_select = [:id,:name,:class_name]
@fonts = Font.all(:fields => fields_to_select).to_json(:only=> fields_to_select)
@fonts