app/controllers/apicasso/crud_controller.rb in apicasso-0.2.11 vs app/controllers/apicasso/crud_controller.rb in apicasso-0.2.12

- old
+ new

@@ -26,11 +26,11 @@ # GET /:resource/1 # Common behavior for showing a record, with an addition of # relation/methods including on response def show set_access_control_headers - render json: @object.to_json(include: parsed_include) + render json: @object.to_json(include: parsed_include, only: parsed_select) end # PATCH/PUT /:resource/1 # Common behavior for an update API endpoint def update @@ -170,9 +170,11 @@ end # Parsed JSON to be used as response payload, with included relations def include_relations @records = JSON.parse(included_collection.to_json(include: parsed_include)) + rescue ActiveRecord::AssociationNotFoundError + @records = JSON.parse(@records.to_json(include: parsed_include)) end # A way to SQL-include for current param[:include], only if available def included_collection @records.includes(parsed_include)