Pug - это препроцессор HTML и шаблонизатор, который был написан на JavaScript для Node.js.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:2.3.1 | |
# Install dependencies | |
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs | |
# Set an environment variable where the Rails app is installed to inside of Docker image: | |
ENV RAILS_ROOT /var/www/app_name | |
RUN mkdir -p $RAILS_ROOT | |
# Set working directory, where the commands will be ran: |
If your master.key has been compromised, you might want to regenerate it.
No key regeneration feature at the moment. We have to do it manually.
- Copy content of original credentials
rails credentials:show
somewhere temporarily. - Remove
config/master.key
andconfig/credentials.yml.enc
- Run
EDITOR=vim rails credentials:edit
in the terminal: This command will create a newmaster.key
andcredentials.yml.enc
if they do not exist. - Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
- Add and Commit the file
config/credentials.yml.enc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record/connection_adapters/sqlite3_adapter' | |
# | |
# Monkey-patch for disable foreign keys during `alter_table` for sqlite3 adapter for Rails 5 | |
# | |
module ActiveRecord | |
module ConnectionAdapters | |
class SQLite3Adapter < AbstractAdapter |
This blogpost shows how to setup Rails 6 with Bootstrap 4.
This snippet shows a somehow different and less customized approach.
$ rails new rails6-bootstrap4
$ bundle --binstubs
$ yarn add bootstrap jquery popper.js expose-loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
store_with S3 do |s3| | |
s3.access_key_id = "your_key" | |
s3.secret_access_key = "your_pass" | |
s3.bucket = "your_bucket_name" | |
s3.path = "your_path_to_backup" | |
s3.region = "ru-central1" | |
s3.fog_options = { endpoint: "https://storage.yandexcloud.net" } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo vi /etc/nginx/sites-enabled/unicorn.qna.conf | |
# это директива nginx которая указывает список бэкенд серверов которые физически будут обрабатывать запрос и таким образом nginx будет проксировать запросы к указанным серверам и даже как loadbalancer | |
upstream unicorn { | |
server unix:/home/deployer/qna/shared/tmp/sockets/unicorn.qna.sock fail_timeout=0; # описали сервер ссылающийся на сокет а можно было на ip и таких серверов может быть несколько, fail_timeout - означает что nginx не будет посылать запросы если наш сервер не отвечает | |
} | |
# к этому никакого отношения upstream не имеет | |
server { | |
listen 80; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby pattern matching based on Type (=> operator) | |
[1,2,3] => [1, Integer, my_variable] | |
# This means: | |
# We want to assign `my_variable` (variable binding), | |
# but only if the first position is 1 and second position is an Integer) | |
my_variable # => 3 ✨ | |
# What if it doesn't match? You get an exception 💣 | |
[1,2,3] => [Integer, String, my_variable] | |
# [1, 2, 3]: String === 2 does not return true (NoMatchingPatternError) |
OlderNewer