app/controllers/apicasso/crud_controller.rb in apicasso-0.2.12 vs app/controllers/apicasso/crud_controller.rb in apicasso-0.2.13
- old
+ new
@@ -26,11 +26,12 @@
# 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, only: parsed_select)
+ byebug
+ render json: show_json
end
# PATCH/PUT /:resource/1
# Common behavior for an update API endpoint
def update
@@ -154,9 +155,19 @@
def index_json
if params[:group].present?
accessible_records.group(params[:group][:by].split(',')).send(params[:group][:calculate], params[:group][:fields])
else
collection_response
+ end
+ end
+
+ # The response for show action, which can be a fieldset
+ # or a full response of attributes
+ def show_json
+ if params[:select].present?
+ @object.to_json(include: parsed_include, only: parsed_select)
+ else
+ @object.to_json(include: parsed_include)
end
end
# Parsing of `paginated_records` with pagination variables metadata
def built_paginated