Files
sx-fc/app/controllers/inventory/stock_journals_controller.rb
Thein Lin Kyaw 937f40e7c1 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
2019-12-02 17:19:28 +06:30

81 lines
2.2 KiB
Ruby
Executable File

class StockJournalsController < ApplicationController
before_action :set_stock_journal, only: [:show, :edit, :update, :destroy]
# GET /stock_journals
# GET /stock_journals.json
def index
@stock_journals = StockJournal.all
end
# GET /stock_journals/1
# GET /stock_journals/1.json
def show
end
# GET /stock_journals/new
def new
@stock_journal = StockJournal.new
end
# GET /stock_journals/1/edit
def edit
end
# POST /stock_journals
# POST /stock_journals.json
def create
@stock_journal = StockJournal.new(stock_journal_params)
respond_to do |format|
if @stock_journal.save
format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully created.' }
format.json { render :show, status: :created, location: @stock_journal }
else
format.html { render :new }
format.json { render json: @stock_journal.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /stock_journals/1
# PATCH/PUT /stock_journals/1.json
def update
respond_to do |format|
if @stock_journal.update(stock_journal_params)
format.html { redirect_to @stock_journal, notice: 'Stock journal was successfully updated.' }
format.json { render :show, status: :ok, location: @stock_journal }
else
format.html { render :edit }
format.json { render json: @stock_journal.errors, status: :unprocessable_entity }
end
end
end
# DELETE /stock_journals/1
# DELETE /stock_journals/1.json
def destroy
@stock_journal.destroy
respond_to do |format|
format.html { redirect_to stock_journals_url, notice: 'Stock journal was successfully destroyed.' }
format.json { head :no_content }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.current_shop
end
private
# Use callbacks to share common setup or constraints between actions.
def set_stock_journal
@stock_journal = StockJournal.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def stock_journal_params
params.fetch(:stock_journal, {})
end
end