Rails Common Commands

A list of frequent Rails command line commands.

  • rvm use ruby-1.9.2-p0 - ruby version manager; switches to Ruby 1.9.2
  • rvm use ruby-1.9.2-p0 --default - ruby version manager; sets 1.9.2 as default
  • rvm use system - ruby version manager; switches to Ruby 1.87
  • rails new - creates a new Rails application
  • rails server [s] - launches WEBrick web server
  • rails generate [g] - lists available generators
  • rails generate controller --help - provides usage documentation
  • rails generate model --help - provides usage documentation
  • rails generate migration --help - provides usage documentation
  • rails destroy controller [Name] - undo generate controller
  • rails destroy model [Name] - undo generate model
  • rails generate scaffold [Name] --skip --no-migration - scaffold skipping existing files
  • rake db:migrate - runs database migrations
  • rake db:test:clone - clones current environment's database schema
  • rake db:test:purge - empties the test database
  • rake routes - list of all of the available routes
  • rake -T - list of rake commands
  • git init - creates git repo
  • git add . - adds all files to working tree
  • git commit -m "Initial commit" - commits files to repo
  • git status - status of the working tree
  • git push origin master - merges local repo with remote
  • git checkout -b new-dev - creates topic branch
  • git checkout master - switches to master branch
  • git merge new-dev - merges new-dev branch into master branch
  • git checkout -f - undo uncommitted changes on working tree
  • git branch - list branches
  • git branch -d modify-README - deletes branch
  • git mv README README.markdown - renames files using move command
  • heroku create - creates app on Heroku servers
  • git push heroku master - pushs app on to Heroku servers
  • heroku rake db:migrate - runs database migrations on Heroku servers
  • heroku pg:reset SHARED_DATABASE --confirm [app name] - deletes database file
  • heroku db:push - transfer an existing database to Heroku.
  • heroku logs - get logs.
  • rails console - command line interface to Rails app
  • rails dbconsole - command line database interface
  • bundle install - installs gems from Gemfile
Advertisements

One thought on “Rails Common Commands

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s