From 37380f6bfb24c0ad4b8421e27fdbb440a826fe92 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Tue, 3 Dec 2019 19:37:59 +0630 Subject: [PATCH] Fix json rendering error --- app/controllers/api/api_controller.rb | 10 +++++++++- app/controllers/application_controller.rb | 4 ++-- app/controllers/base_controller.rb | 5 +++-- app/controllers/base_crm_controller.rb | 4 +++- app/controllers/base_inventory_controller.rb | 4 +++- app/controllers/base_oqs_controller.rb | 4 +++- app/controllers/base_origami_controller.rb | 4 +++- app/controllers/base_report_controller.rb | 4 +++- app/controllers/base_waiter_controller.rb | 4 +++- app/controllers/concerns/multi_tenancy.rb | 1 - 10 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 8a84cfa1..0cf85065 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,11 +1,19 @@ class Api::ApiController < ActionController::API - include TokenVerification, MultiTenancy + include MultiTenancy + include TokenVerification include ActionController::MimeResponds + include ActionView::Rendering # before_action :lookup_domain helper_method :current_token, :current_login_employee, :get_cashier private + # ActionView::Rendering override render_to_body breaks render :json, + # resulting in an ActionView::MissingTemplate error. + def render_to_body(options) + _render_to_body_with_renderer(options) || super + end + #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 81b4835d..8f537383 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification #before_action :check_installation protect_from_forgery with: :exception @@ -17,5 +18,4 @@ class ApplicationController < ActionController::Base flash[:warning] = exception.message redirect_to root_path end - end diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 1bb0421e..22cbf130 100755 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -1,6 +1,7 @@ class BaseController < ActionController::Base include MultiTenancy - layout "installation" - protect_from_forgery with: :exception + layout "installation" + + protect_from_forgery with: :exception end diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 08bc8138..577c387e 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,5 +1,7 @@ class BaseCrmController < ActionController::Base - include LoginVerification, + include MultiTenancy + include LoginVerification + layout "CRM" before_action :check_user diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index bd455c33..45fa8954 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,5 +1,7 @@ class BaseInventoryController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "inventory" before_action :check_user diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index 6e6a9c0f..6b01383d 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,5 +1,7 @@ class BaseOqsController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "OQS" before_action :check_user diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index e9cddf05..e3daff76 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,5 +1,7 @@ class BaseOrigamiController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "origami" before_action :check_user diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index b3d1d23a..a4c7c3c3 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,5 +1,7 @@ class BaseReportController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "application" before_action :check_user diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index b1d2056c..0962b3f0 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,5 +1,7 @@ class BaseWaiterController < ActionController::Base - include LoginVerification, MultiTenancy + include MultiTenancy + include LoginVerification + layout "waiter" before_action :check_user diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb index 5009e094..cb7c8aae 100644 --- a/app/controllers/concerns/multi_tenancy.rb +++ b/app/controllers/concerns/multi_tenancy.rb @@ -4,7 +4,6 @@ module MultiTenancy included do set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action - helper_method :current_shop if respond_to? :helper_method end private