📑
Chris Johnson's KB
  • Chris Johnson's KB
  • Meta
    • Pages to Add
  • Cheat Sheets
    • Apache
    • Docker
    • Gatsby
    • Git
    • GraphQL
    • iOS
    • MySQL
    • Nginx
    • NextJS
    • NodeJS
    • Rails
    • React
    • Security Tools
    • Shell (Linux)
    • SwiftUI
    • Ubuntu Server
    • Vim
  • Computing
    • Mac
    • iOS
    • ChromeOS
    • Windows
    • Browser Plugins
    • RSI Prevention
    • Voice Control
    • AWS Cloud 9
    • Visual Studio Code
    • Linux
  • Workflows
    • Podcasting
    • Setting up a new Mac
    • Site Deploys
  • Hardware
    • Dell U2720Q Monitor
    • Moonlander Keyboard
    • Apple Silicon Macs
  • Productivity
    • Structure
    • Nuggets of Wisdom
  • Coffee
    • Coffee Notes & Equipment
    • Coffee Beans
    • AeroPress Recipes
    • V60 Recipes
    • Moka Pot Recipes
    • French Press Recipes
  • Gaming
    • Rocket League
  • Food
    • Cocktails
    • Favorite Recipes
    • Whisky Reviews
    • Infinity Bottle
    • Favorite Wines
  • Inspiration
    • Quotes
  • Philosophy
    • Life
    • Programming
  • Fitness
    • Diets
    • Exercise Notes
    • Personal Training Notes
Powered by GitBook
On this page
  • RBEnv
  • Ruby Gems
  • Bundler
  • Rails
  • Capistrano
  • Heroku
  • Dokku

Was this helpful?

  1. Cheat Sheets

Rails

PreviousNodeJSNextReact

Last updated 3 years ago

Was this helpful?

List current ruby version: rbenv versions

Set local/directory version of ruby:rbenv local <VERSION>

After installing a gem that adds new binaries (new commands):rbenv rehash

Updating gem system:gem update --system --no-document

Install gems from current bundle:bundle install or: bundle install --without production

Run an executable that comes with a gem in your bundle:bundle exec <GEM COMMAND>

Update one gem: bundle update --conservative <GEM NAME>

Create a new Rails project:rails new <APP NAME>

Create Rails database:rake db:create

Update Rails database:rake db:migrateor:rake db:migrate RAILS_ENV=production

Run Rails server:rails server

Rails console:rails console --sandbox

Rails console bypass model validation:XXXXXX.update(admin: true) XXXXXX.save(:validate => false)

Capistrano

Deploy:bundle exec cap TASKHERE deploy

Heroku

Create app:heroku create

Push app:git push heroku master

Auth Heroku: heroku auth:login

Open app:heroku open

Run console:heroku run rails console

Migrate database:heroku run rake db:migrate

If you want to run sqlite locally and pg on heroku, your gemfile needs to look like this:

group :development do
   gem 'sqlite3'
end

group :production do
   gem 'pg'
end

You may need to add the Ruby version to your gemfile as well:ruby '1.9.3'

To get your assets to properly compile on heroku, change your production.rb file to say true here instead of false:config.assets.compile = true

Deploy with branch name other than master or main: git push heroku my-branch:main

Dokku

Push app:git push dokku master

In your production group, you'll likely want these two gems:

gem 'pg' # postgres
gem 'rails_12factor' # for logging

SSH into server to run dokku commands. Use dokku --help for list of commands.

.

.

RBEnv
Ruby Gems
Bundler
Rails
Deploy to heroku through git
Use git to deploy Heroku app