Veerasundaravel's Ruby on Rails Weblog

October 7, 2010

Useful Rails Commands – Cheatsheet

Filed under: Ruby On Rails — Tags: , , , , , , , — Veerasundaravel @ 3:08 pm

These are the commands,  we ROR folks use often in development. Please refer and let me know if there is any missing.

rails ApplicationName – Create a new application
ruby script/generate model ModelName – Creates a model with the specified model_name
ruby script/generate controller ControllerName – Creates a controller with the specified controller_name
ruby script/generate migration MigrationName – Creates a migration with the specified migration_name
ruby script/generate scaffold ModelName ControllerName – A shortcut for creating your controller, model and view files etc.
ruby script/destroy controller ControllerName – Destroys the created controller and its related file. Same way you can destroy your model, migration files etc.
ruby script/server – start ruby server at http://localhost:3000
ruby script/plugin install PluginName – Installs the specified plugin.
ruby script/console – Opens the rails console for the current RAILS_ENV
ruby script/dbconsole – Opens the DB console for the current RAILS_ENV
ruby script/performance – For benchmarkering and profiling your application.

rake –tasks – Lists all available rake tasks
rake db:create – Create the database defined in config/database.yml for the current RAILS_ENV
rake db:drop – Drops the database for the current RAILS_ENV
rake db:migrate – Migrate the database through scripts in db/migrate folder.
rake db:reset – Drops and recreates the database from db/schema.rb for the current environment.
rake db:schema:dump – Create a db/schema.rb file that can be portably used against any DB supported by AR
rake doc:app – Build the RDOC HTML Files
rake db:sessions:create – Creates a sessions migration for use with CGI::Session::ActiveRecordStore
rake gems – List the gems that this rails application depends on
rake gems:install – Installs all required gems for this application.
rake log:clear – Truncates all *.log files in log/ to zero bytes
rake rails:freeze:gems – Lock this application to the current gems (by unpacking them into vendor/rails)
rake routes – Print out all defined routes in match order, with names.
rake test – Run all unit, functional and integration tests
rake test:functionals – Run tests for functionalsdb:test:prepare / Run the functional tests in test/functional
rake test:integration – Run tests for integrationdb:test:prepare / Run the integration tests in test/integration
rake test:units – Run tests for unitsdb:test:prepare / Run the unit tests in test/unit
rake tmp:clear – Clear session, cache, and socket files from tmp/

gem list – Lists all the installed gems.
gem install GemName – Installs the specified gem in to your machine.
gem uninstall GemName – Uninstalls the specified gem from your machine.
gem server – present a web page at http://localhost:8808/ with info about installed gems.

Alos refer:

Useful Rails3 Commands & Cheatsheet
Useful SVN and Git commands – Cheatsheet


  1. […] Useful Rails Commands & Cheatsheet Useful SVN and Git commands – Cheatsheet […]

    Pingback by Useful Rails3 Commands – Cheatsheet « Veerasundaravel's Ruby on Rails Weblog — October 7, 2010 @ 3:09 pm

  2. Nice Veera :)

    Comment by raveendran — October 7, 2010 @ 10:06 pm

  3. @Ravi Thank you very much Ravi…

    Comment by veerasundaravel — October 8, 2010 @ 11:30 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: