Preview:
# Config for bundle to only install the dev + test gems
bundle config set --local without production

# Kill a stuck rails s
# 1. Find the PID number
cat tmp/pids/server.pid
# 2. Kill the process with that PID number
kill -9 <PID>

# Generate a model
rails generate model YourModelNameHere (singular)

# Generate a migration
rails generate migration NameYourMigration

# Revers the last migration
rails db:rollback

# Open the Rails console
rails c

################################ Rails console ################################

# Reload console
reload!

# Create a new instance variable
u = User.new

# Check if valid
u.valid?

# Check for any errors
u.errors.full_messages

# Retrieve all the posts from your first user
User.first.posts

# Using #build to create a new post from a user (if associations were placed)
upnew = User.first.posts.new
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter