Veerasundaravel's Ruby on Rails Weblog

October 7, 2010

Useful Rails3 Commands – Cheatsheet

Some of useful Rails3 Commands and their descriptions are listed below:

rails new ApplicationName – Create a new application
rails generate/g model ModelName – Creates a model with the specified model_name
rails generate/g controller ControllerName – Creates a controller with the specified controller_name
rails generate/g migration MigrationName – Creates a migration with the specified migration_name
rails generate/g scaffold ModelName ControllerName – A shortcut for creating your controller, model and view files etc.
rails destroy controller ControllerName – Destroys the created controller and its related file. Same way you can destroy your model, migration files etc.
rails server/s – start ruby server at http://localhost:3000
rails plugin install PluginName – Installs the specified plugin.
rails console/c – Opens the rails console for the current RAILS_ENV
rails dbconsole/db – Opens the DB console for the current RAILS_ENV
rails 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:rollback – This will run the down method from the latest migration.
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.

Also Refer:

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

Advertisements

10 Comments »

  1. Thanks :)

    для сайта veerasundaravel.wordpress.com

    Comment by Kontact — November 6, 2010 @ 5:02 am

  2. how are you I was luck to find your theme in digg
    your Topics is impressive
    I obtain a lot in your blog really thanks very much
    btw the theme of you blog is really admirable
    where can find it

    Comment by bet365 — November 24, 2010 @ 11:54 pm

  3. Hi bet365,

    First thanks a lot for your comment. And this theme name is ‘Silver is the New Black’. But now I can’t this theme in the listing.

    If you want the CSS of this theme means, I can send it to you.

    Comment by veerasundaravel — November 25, 2010 @ 12:14 pm

  4. Way cool thx a bunch!

    Comment by RideRails — January 15, 2011 @ 1:49 am

  5. […] A big thanks to CLICK HERE! […]

    Pingback by Useful Rails 3 Commands « Riding with Rails (and Ruby) — January 15, 2011 @ 1:52 am

  6. Hi!
    That’s a great cheatsheet, but I would also add rollback command, for migrations.
    See you!

    Comment by Lucas — March 15, 2011 @ 6:43 pm

    • thanks for the suggestion. Updated the post with rollback command.

      Comment by Veerasundaravel — March 16, 2011 @ 2:47 pm

  7. Thanks a milion for your personal concern along with work! These things on the site can be wonderful. Additionally My spouse and i considerably recognize your current creative ideas. In my opinion these are generally very important factors. Anyways bless you. Decent read.

    Comment by Digna Stoudemire — April 13, 2011 @ 2:35 pm

  8. […] Useful Rails3 Commands – Cheatsheet « Veerasundaravel's Ruby on Rails Weblog (tags: rails rails3 ror ruby rubyonrails) AKPC_IDS += "527,";Popularity: unranked [?] […]

    Pingback by links for 2011-04-25 | Digitalistic - Mashup or die trying — April 25, 2011 @ 7:33 pm

  9. Don’t forget:

    rails g scaffold_controller ModelName

    which generates a scaffolded controller with views for the basic CRUD actions. (Does not create migration.)

    Comment by magnemg — August 2, 2011 @ 6:26 pm


RSS feed for comments on this post. TrackBack URI

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

%d bloggers like this: