ruby on rails - Datamapper "Model.all()" method creates 3 selects and not selecting the right fields -
i've started use datamapper padrino , have weird issue. issues explained below:
1.the code:
content_type :json @fonts = font.all(:fields=>[:id,:name,:class_name]) @fonts.to_json - datamapper executes 3 queries , return me result fields.
please see sql queries executed:
debug - (0.000087) select id, name, class_name fonts order id
debug - (0.000205) select id, post_script_name, designer, license, category, full_name, style, weight, filename, copyright, system_file_path, http_path, ext fonts order id
debug - (0.000158) select id, font_face fonts order id
please me why it's happening ?
thank 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
Comments
Post a Comment