summaryrefslogtreecommitdiff
path: root/app/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/companies_controller.rb4
-rw-r--r--app/controllers/api/products_controller.rb11
2 files changed, 11 insertions, 4 deletions
diff --git a/app/controllers/api/companies_controller.rb b/app/controllers/api/companies_controller.rb
index 086ac5b..973eedb 100644
--- a/app/controllers/api/companies_controller.rb
+++ b/app/controllers/api/companies_controller.rb
@@ -4,7 +4,7 @@ module Api
# CompaniesController
class CompaniesController < MasterController
def index
- @companies = Company.page(params[:page])
+ @companies = Company.all
render json: serialized_collection.serializable_hash, status: 200
end
@@ -44,7 +44,7 @@ module Api
end
def serialized_collection
- Serializers::CompanySerializer.new(@companies.page(params[:page]))
+ Serializers::CompanySerializer.new(@companies.includes(logo_attachment: :blob).page(params[:page]))
end
def permitted_params
diff --git a/app/controllers/api/products_controller.rb b/app/controllers/api/products_controller.rb
index 213fa9f..2822a21 100644
--- a/app/controllers/api/products_controller.rb
+++ b/app/controllers/api/products_controller.rb
@@ -49,11 +49,18 @@ module Api
private
def serialized_object
- Serializers::ProductSerializer.new(@product)
+ Serializers::ProductSerializer.new(
+ @product.joins(:company)
+ .select('products.*', 'companies.name as company_name','companies.short_name as company_short_name')
+ )
end
def serialized_collection
- Serializers::ProductSerializer.new(@products.page(params[:page]))
+ Serializers::ProductSerializer.new(
+ @products.joins(:company)
+ .select('products.*', 'companies.name as company_name', 'companies.short_name as company_short_name')
+ .includes(picture_attachment: :blob).page(params[:page])
+ )
end
def permitted_params