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 
  1. 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

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -