rails CLI +
Tue May 10 2022 13:31:46 GMT+0000 (Coordinated Universal Time)
Saved by
@organic_darius
# 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
content_copyCOPY
Comments