Single database for multiple shops

Use ActsAsTenant as Multi-tenancy for shops

See below files:
- app/controllers/concern/multi_tenancy.rb
- app/models/application_record.rb
- app/models/shop.rb

An initializer can be created to control option in ActsAsTenant.
config/initializers/acts_as_tenant.rb
require 'acts_as_tenant/sidekiq'
ActsAsTenant.configure do |config|
  config.require_tenant = false # true
end

more details: https://github.com/ErwinM/acts_as_tenant
This commit is contained in:
Thein Lin Kyaw
2019-12-02 17:19:28 +06:30
parent 5d10d4b6a1
commit 937f40e7c1
78 changed files with 215 additions and 173 deletions

View File

@@ -1,5 +1,5 @@
class Api::ApiController < ActionController::API
include TokenVerification
include TokenVerification, MultiTenancy
include ActionController::MimeResponds
# before_action :lookup_domain

View File

@@ -106,7 +106,7 @@ class Api::BillController < Api::ApiController
# unique_code = "ReceiptBillPdf"
# #shop detail
# shop_details = Shop.find(1)
# shop_details = Shop.current_shop
# customer= Customer.find(@sale_data.customer_id)
# # get member information

View File

@@ -23,7 +23,7 @@ class Api::CallWaitersController < ActionController::API
end
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids
# get printer info
@shop = Shop.first
@shop = Shop.current_shop
unique_code = "CallWaiterPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)

View File

@@ -70,7 +70,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation)
if !order_reservation_id.nil? && flag
shop = Shop.find_by_id(1)
shop = Shop.current_shop
if !shop.nil?
shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")

View File

@@ -46,7 +46,7 @@ class Api::OrdersController < Api::ApiController
@tax_profile = TaxProfile.where("lower(group_type)='cashier'")
# end
@shop = Shop.first
@shop = Shop.current_shop
puts "Hello world"
puts @shop.to_json
return @shop.to_json

View File

@@ -14,7 +14,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController
saleObj = Sale.find(sale_id)
sale_items = SaleItem.get_all_sale_items(sale_id)
shop_detail = Shop.first
shop_detail = Shop.current_shop
# rounding adjustment
if !path.include? ("credit_payment")

View File

@@ -2,7 +2,7 @@ class Api::SoundEffectController < Api::ApiController
#sound effect / alarm api for doemal side calling
def sound_effect
shop = Shop.find_by_id(1)
shop = Shop.current_shop
if !shop.nil?
shop_code = shop.shop_code
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")