Homepage for Pat Schreiber.
Current Project Dependency | Version |
---|---|
Ruby | 2.7.x |
Rails | 6.x |
cd /path/to/project/root
RVM is a handy way to manage multiple ruby installations on a single host, say, if said host is running multiple applications that require different Ruby versions. It's also handy for testing new language releases. An optional install, but highly suggested.
# Update RVM
rvm get head
# Install latest project ruby version
# rvm install ruby-major.minor.revision
# E.g.
rvm install 2.7.1
# Create a gemset for this project
rvm create gemset patschreiber
Note:
The ruby version and RVM wrapper should switch to the correct versions (if
they're installed) automatically based on the ruby-version
and .ruby-gemset
files located at the root of the project. If they do not, run rvm use 2.7.1@patschreiber
to manually switch.
# Installs Ruby Gems
bundle install
# Initializes the database
rake db:setup
# Alternatively, if the db is alreay created, you can run
rake db:migrate
rake db:seed
# Install the Rails Webpack helper
rake webpacker:install
rake webpacker:compile
Install automatic cert updating
rvm osx-ssl-certs cron install
If you're returning to the project, follow these steps.
cd /path/to/project/root
bundle update
bundle install
rvm get head
# Verifies if Node.js is installed
rake webpacker:check_node
# Verifies if Yarn is installed
rake webpacker:check_yarn
# Verifies that webpack & webpack-dev-server are present
rake webpacker:check_binstubs
# Verifies if Webpacker is installed
rake webpacker:verify_install
webpacker:clean
webpacker:install
webpacker:binstubs
webpacker:compile
rake db:migrate
rake db:schema:load
- Auto generates HAML rubocop suggestions
haml-lint --auto-gen-config
- Generate warnings for Ruby code
bundle exec rubocop
To have Rubocop auto-fix a single rule, you can run:
rubocop --auto-correct --only Style/FrozenStringLiteralComment
where the name of the rule is defined in .rubocop.yml
.
-[] Update outdated packages -[] Check SSL Cert
rvm default <ruby version>@<gemset>
e.g. rvm default 2.7.1@patschreiber
cd /path/to/project/root
rvm get head
Migrate using the RVM syntax:
rvm migrate old ruby version (source) ruby version (destination)`
E.g.
rvm migrate 2.6.5 2.7.1
- Get a list of outdated gems.
bundle outdated
- Update a single gem.
bundle update <package>
- Update a specific group of gems.
bundle update --group=GROUP_NAME
- Update all gems.
bundle update --all
Create or rebuild your sitemap files as needed. Sitemaps are generated into the public/ folder and by default are named sitemap.xml.gz, sitemap1.xml.gz, sitemap2.xml.gz, etc. As you can see, they are automatically GZip compressed for you. In this case, sitemap.xml.gz is your sitemap "index" file.
-
Clear existing sitemaps
- Delete all Sitemap files in public/ directory
rake sitemap:clean
- Delete all Sitemap files in public/ directory
-
Generate sitemaps
- Generate sitemaps and ping search engines
rake sitemap:refresh
- Generate sitemaps but don't ping search engines
rake sitemap:refresh:no_ping
- Generate sitemaps and ping search engines
-
Regenerate pretty URLs (friendly_ids)
Note
All commands should be run on the prod server(s).
-
Clear tmp dirs
rake tmp:clear
-
Creates tmp directories for cache, sockets, and pids
rake tmp:create
-
Clean old compiled webpacks
rake webpacker:clean
-
Compile JavaScript packs using webpack for production with digests
rake webpacker:compile
-
Creates a db/schema.rb file that is portable against any DB supported by Active Record
rake db:schema:dump
-
Retrieves the current schema version number
rake db:version
- Regenerate hashes
rake secure_headers:generate_hashes
- Recreates the database from the schema.rb file.
rake db:schema:load
- Set the current RAILS_ENV environment in the ar_internal_metadata table. (Used as part of the protected environment check.)
rake db:environment:set
- Checks if a destructive action can be performed in the current RAILS_ENV environment. Used internally when running a destructive action such as db:drop or db:schema:load.
rake db:check_protected_environments
Note Be aware of gems that are installed outside of bundler. e.g. gem install bundler -v 1.17.2
Create or rebuild your sitemap files as needed. Sitemaps are generated into the public/ folder and by default are named sitemap.xml.gz, sitemap1.xml.gz, sitemap2.xml.gz, etc. As you can see, they are automatically GZip compressed for you. In this case, sitemap.xml.gz is your sitemap "index" file.
rake sitemap:refresh
Generate sitemaps but don't ping search engines
rake sitemap:refresh:no_ping
Cron is run through the whenever
gem and configured in config/schedule.rb
.
Cron log is assumed to be /var/log/cron.log
. See https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log for more info.
Writes the crontab file for your jobs
whenever --update-crontab
- Edit Keys
EDITOR=vim rails credentials:edit
- Use a key
Rails.application.credentials.secret_key_base
Add Pretty URLs to already-existing entities
Project.find_each(&:save)
"Projects" use the title by default, but you can set your own slug using
lambda {
project = Project.new
project.source_type = 'open'
project.slug = 'my-long-project-pretty-URL'
# etc...
}
rails g migration AddSlugToUsers slug:uniq
# Init Webpack
bundle exec rails webpacker:install
# Run Webpack
./bin/webpack-dev-server
Most of the systems ships with a package manager so the enable
mode is the same as packages
.
Unfortunately on OSX there is not package manger provided so RVM has to detect one of existing user efforts,
The detection is in order: homebrew
, macports
, smf
, fink
if none of them are available then RVM will install macports
.
rvm autolibs enable
You can also optionally enforce a package manager by using one of the following instead of enable
:
macports
, homebrew
, fink
, smf
(SM Framework) or rvm_pkg
(the old rvm pkg
), like:
-
rvm autolibs homebrew
-
bundle install
cd /path/to/patschreiber_root/ && bundle install
-
rvm
rvm use <ruby version>@<your gemset>