Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Backend Handbook

Generate Documentation

We use Yard to document our app, to see the doc, run this in your terminal

bundle exec yard doc -c

Open doc/index.html in your web browser

Entity Relationship Diagram (ERD)

How to test the email template / email delivery on local

install mailcatcher gem then run it, and see how to do it on GitHub run sidekiq, and try to execute Mailer class, for example: UserMailer.booking_confirmation(xxx).deliver then check on mailcatcher UI, see

Gems that we use (Gemfile)

Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15682) Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15702) Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15722)

Fixing a bug / Adding a new features on user app

  • Ask to FE team, "What API do you use for that update?" or you can check it yourself using the Chrome network console.
  • It's usually in controllers at api/v5/xxx.
  • If the bug is in the reviews feature, then check api/v5/reviews_controller.
  • As for the data returned by the API V5 controller, everything is manipulated or serialized by the active-model-serializer gem, and the location is in app/serializers/api/v5. Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15742) Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15762)

User types

Admin

User type ADMIN is an user that on User Model the provider coloumn has google_oauth2

  def staff_signed_in?
    user_signed_in? && current_user.provider.to_s == 'google_oauth2'
  end

User

User type USER is an user that on User Model the provider coloumn has null, “facebook”, or “firebase” value

Staff Restoran

User type that can access owner (restaurant) dashboard

  1. Owner
  2. Restaurant Group
  3. Staff You can read here for more information Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15782)

Cron Job

https://github.com/sidekiq-scheduler/sidekiq-scheduler Screen Recording 2022-09-28 at 17.08.12.mov

Database migration best practices

Read https://github.com/ankane/strong_migrations we use this gem to migrate our data safely in production

How to fix slow old staging server

service redis stop
rm -rf /var/lib/redis/*.rdb
service redis start
# lalu matikan dan idupkan lagi sidekiq dan server nya

Private (https://app.clickup.com/9003122396/docs/8ca1fpw-14502/8ca1fpw-15802)

How to add authorization to a resource

we use https://github.com/varvet/pundit for the authorization the usage is pretty easy, as you see in the README example:

class ReservationPolicy < ApplicationPolicy
  def initialize(user, object)
    super(user, reservation)
  end

  def editable?
    # xxx
  end
end

policy = ::ReservationPolicy.new(current_staff, @reservation)
if policy.editable?
  # xxx
end