ruby on rails 4 - N+1 Query Issue -
i can't understand why bullect gem complaining n+1 queries when included in query
issue
n+1 query detected
addontypevalue => [:addon_option_values] add finder: :includes => [:addon_option_values]
query
addon_types = addontype.includes(addon_type_values: [addon_option_values: :addon_option_type]). where(addon_type_values: {published: true, design_id: self.id}). where{addon_type.addon_type_values.visible_for != not_for}
my view - jbuilder
json.addon_option_values addon_type_value.addon_option_values |aov| json.id aov.id json.p_name aov.p_name json.position aov.position end
request output log - n+1 query method call stack
/app/views/api/v1/designs/show.json.jbuilder:45:in `block (2 levels) in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:39:in `block in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:35:in `_app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:45:in `block (2 levels) in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:39:in `block in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:35:in `_app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
Comments
Post a Comment