We used the official Capistrano recipe for Puma. capistrano-puma. It has monit scripts built-in to monitor puma server processes
OS level
sudo apt-get update| # When you didn't shutdown the server wisely, | |
| # you will encounter error that tells you the certain port is in use | |
| # specially when running rails server | |
| kill -9 $(lsof -i tcp:4000 -t) | |
| # Note: | |
| Change the `4000` upon on the port you are running on it |
| # frozen_string_literal: true | |
| # Add `AuthenticationHelper` in spec/support/authentication_helper.rb | |
| module AuthenticationHelper | |
| def generate_token(user) | |
| payload = { id: user.id.to_s } | |
| JWT.encode payload, Rails.application.credentials.secret_key_base, 'HS256' | |
| end | |
| def sign_in(user) |
We used the official Capistrano recipe for Puma. capistrano-puma. It has monit scripts built-in to monitor puma server processes
OS level
sudo apt-get updateTable of Contents
| # Create a proxy server that forwards requests to thirdparty | |
| # 1) Create a file in `/etc/nginx/sites-available` and name it any name | |
| # 2) Copy the script replace `server_name` with your server domain and `proxy_pass` with third party domain. | |
| server { | |
| listen 80; | |
| server_name YourDomain.com; | |
| location / { | |
| proxy_pass https://ThirdPartyDomain.com; | |
| #proxy_ssl_certificate /etc/nginx/ssl; |
| # This document will help you setting up a Ruby on Rails development environment on Ubuntu and macOS. | |
| # ---------------------------------------- Ubuntu ------------------------------------------------------ # | |
| # To make sure we have everything necessary for Webpacker support in Rails, | |
| # we're first going to start by adding the Node.js and Yarn repositories to our system before installing them. | |
| - sudo apt-get update | |
| - sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn | |
| # Next we're going to be installing Ruby using one of RVM. |
| 1) cd ~ | |
| 2) mv .zsh_history .zsh_history_bad | |
| 3) strings .zsh_history_bad > .zsh_history | |
| 4) fc -R .zsh_history # reload history |
| module Attachable | |
| extend ActiveSupport::Concern | |
| included do | |
| ## -------------------- Associations -------------------- ## | |
| if const_defined?('STORAGE_TYPES') | |
| self::STORAGE_TYPES.each do |k, v| | |
| v == :one ? has_one_attached(k.to_sym) : has_many_attached(k.to_sym) | |
| end | |
| end |
| # Encrypts and Decrypts block of data given an encryption key and an | |
| # initialization vector (iv). Keys, iv's, and the data returned | |
| # are all binary strings. Cipher algorithm should be array [256, CBC], | |
| # or any of the cipher types supported by OpenSSL otherwise default will be used. | |
| # Pass nil if the encryption type doesn't use iv's (like ECB) or ignore it if you using. | |
| # USAGE: | |
| # encrypt_to_hex_format( | |
| # 'ThisPasswordIsReallyHardToGuess', 'initializervector', 'Hey! please encrypt me' | |
| # ) |
| # app/views/shared/_alerts.html.erb | |
| <% flash.each do |key, value| %> | |
| <div class="alert alert-<%= alert_style(key) %>"><%= value %></div> | |
| <% end %> |