Rails CLI Commands
Use these commands from the root of a Rails project.
Project commands
Section titled “Project commands”Start the Rails server.
bin/rails serverOpen the Rails console.
bin/rails consoleCheck available Rails commands.
bin/rails --helpDatabase commands
Section titled “Database commands”Create the database.
bin/rails db:createRun migrations.
bin/rails db:migrateRollback the last migration.
bin/rails db:rollbackReset the database.
bin/rails db:drop db:create db:migrateSeed the database.
bin/rails db:seedGenerate files
Section titled “Generate files”Generate a model.
bin/rails generate model Post title:string body:textGenerate a controller.
bin/rails generate controller Pages homeGenerate a scaffold.
bin/rails generate scaffold Post title:string body:textUndo a generator.
bin/rails destroy scaffold PostRoutes
Section titled “Routes”List routes.
bin/rails routesSearch routes.
bin/rails routes | grep usersRun the test suite.
bin/rails testRun one test file.
bin/rails test test/models/user_test.rb