diff --git a/app/controllers/storage_location_repository_rows_controller.rb b/app/controllers/storage_location_repository_rows_controller.rb index bab428d80..416a96536 100644 --- a/app/controllers/storage_location_repository_rows_controller.rb +++ b/app/controllers/storage_location_repository_rows_controller.rb @@ -20,7 +20,9 @@ class StorageLocationRepositoryRowsController < ApplicationController @storage_location_repository_row.update(storage_location_repository_row_params) if @storage_location_repository_row.save - render json: {} + render json: @storage_location_repository_row, + serializer: Lists::StorageLocationRepositoryRowSerializer, + include: :repository_row else render json: @storage_location_repository_row.errors, status: :unprocessable_entity end @@ -30,12 +32,14 @@ class StorageLocationRepositoryRowsController < ApplicationController @storage_location_repository_row = StorageLocationRepositoryRow.new( repository_row: @repository_row, storage_location: @storage_location, - metadata: storage_location_repository_row_params[:metadata], + metadata: storage_location_repository_row_params[:metadata] || {}, created_by: current_user ) if @storage_location_repository_row.save - render json: {} + render json: @storage_location_repository_row, + serializer: Lists::StorageLocationRepositoryRowSerializer, + include: :repository_row else render json: @storage_location_repository_row.errors, status: :unprocessable_entity end @@ -53,7 +57,7 @@ class StorageLocationRepositoryRowsController < ApplicationController def load_storage_location_repository_row @storage_location_repository_row = StorageLocationRepositoryRow.find( - storage_location_repository_row_params[:storage_location_id] + storage_location_repository_row_params[:id] ) render_404 unless @storage_location_repository_row end diff --git a/app/controllers/storage_locations_controller.rb b/app/controllers/storage_locations_controller.rb index 309167cc1..bea2d3b60 100644 --- a/app/controllers/storage_locations_controller.rb +++ b/app/controllers/storage_locations_controller.rb @@ -15,7 +15,7 @@ class StorageLocationsController < ApplicationController @storage_location.update(storage_location_params) if @storage_location.save - render json: {} + render json: @storage_location, serializer: Lists::StorageLocationSerializer else render json: @storage_location.errors, status: :unprocessable_entity end @@ -29,7 +29,7 @@ class StorageLocationsController < ApplicationController @storage_location.image.attach(storage_location_params[:signed_blob_id]) if storage_location_params[:signed_blob_id] if @storage_location.save - render json: {} + render json: @storage_location, serializer: Lists::StorageLocationSerializer else render json: @storage_location.errors, status: :unprocessable_entity end diff --git a/app/models/storage_location.rb b/app/models/storage_location.rb index 8249b7667..40e3d767d 100644 --- a/app/models/storage_location.rb +++ b/app/models/storage_location.rb @@ -19,7 +19,7 @@ class StorageLocation < ApplicationRecord validates :name, length: { maximum: Constants::NAME_MAX_LENGTH } after_discard do - StorageLocation.where(parent_id: id).each(&:discard) + StorageLocation.where(parent_id: id).find_each(&:discard) storage_location_repository_rows.each(&:discard) end end diff --git a/app/services/lists/storage_location_repository_rows_service.rb b/app/services/lists/storage_location_repository_rows_service.rb index 6f671b8ab..bb3abe765 100644 --- a/app/services/lists/storage_location_repository_rows_service.rb +++ b/app/services/lists/storage_location_repository_rows_service.rb @@ -12,7 +12,6 @@ module Lists @records = StorageLocationRepositoryRow.includes(:repository_row).where(storage_location_id: @storage_location_id) end - def filter_records - end + def filter_records; end end end diff --git a/app/services/lists/storage_locations_service.rb b/app/services/lists/storage_locations_service.rb index e802be6f6..9829a243e 100644 --- a/app/services/lists/storage_locations_service.rb +++ b/app/services/lists/storage_locations_service.rb @@ -12,7 +12,6 @@ module Lists @records = StorageLocation.where(team: @team, parent_id: @parent_id) end - def filter_records - end + def filter_records; end end end