This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Developing a Quick Reference


Collablorative work editing, modifying and adding to the beginners quick reference guide:

RAILS QUICK Reference

Note: colon and pound sign NOT part of command statement.

rails new <name of directory> : Creates the project directory.
rake db:create : Creates the database using the default SQLite.

rake -T :  Shows the commands.
rails s : Start the rails server.
ctrl C :   Stops the rails server.
http://localhost:3000 :  Default webpage indicates that it is working.

rails generate controller home index : Rails generated the home controller and View in the app directory which is where you mainly will be working in.

By typing "rails" and "rails generate" in the command line, a list of commands are displayed:

Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate :    Generate new code (short-cut alias: "g")
 console :     Start the Rails console (short-cut alias: "c")
 server :      Start the Rails server (short-cut alias: "s")
 dbconsole :   Start a console for the database specified in config/database.yml
             (short-cut alias: "db")
 new:          Create a new Rails application. "rails new my_app" creates a
             new application called MyApp in "./my_app"

In addition to those, there are:
 application :  Generate the Rails application code
 destroy :      Undo code generated with "generate"
 benchmarker :  See how fast a piece of code runs
 profiler :     Get profile information from a piece of code
 plugin :       Install a plugin
 runner :       Run a piece of code in the application environment (short-cut alias: "r")


Usage: rails generate GENERATOR [args] [options]

All commands can be run with -h for more information. *Note - colon for Generator is part of command.

General options:
  -h, [--help]     # Print generator's options and usage
  -p, [--pretend]  # Run but do not make any changes
  -f, [--force]    # Overwrite files that already exist
  -s, [--skip]     # Skip files that already exist
  -q, [--quiet]    # Suppress status output

List of generators below.

Rails:
  assets
  controller
  generator
  helper
  integration_test
  mailer
  migration
  model
  observer
  performance_test
  plugin
  resource
  scaffold
  scaffold_controller
  session_migration

Coffee:
  coffee:assets

Jquery:
  jquery:install

Js:
  js:assets

Usage: rake COMMAND [args]

rake -T : List all commands

rake about              # List versions of all Rails frameworks and the env...
rake assets:clean       # Remove compiled assets
rake assets:precompile  # Compile all the assets named in config.assets.pre...
rake db:create          # Create the database from config/database.yml for ...
rake db:drop            # Drops the database for the current Rails.env (use...
rake db:fixtures:load   # Load fixtures into the current environment's data...
rake db:migrate         # Migrate the database (options: VERSION=x, VERBOSE...
rake db:migrate:status  # Display status of migrations
rake db:rollback        # Rolls the schema back to the previous version (sp...
rake db:schema:dump     # Create a db/schema.rb file that can be portably u...
rake db:schema:load     # Load a schema.rb file into the database
rake db:seed            # Load the seed data from db/seeds.rb
rake db:setup           # Create the database, load the schema, and initial...
rake db:structure:dump  # Dump the database structure to an SQL file
rake db:version         # Retrieves the current schema version number
rake doc:app            # Generate docs for the app -- also available doc:r...
rake log:clear          # Truncates all *.log files in log/ to zero bytes
rake middleware         # Prints out your Rack middleware stack
rake notes              # Enumerate all annotations (use notes:optimize, :f...
rake notes:custom       # Enumerate a custom annotation, specify with ANNOT...
rake rails:template     # Applies the template supplied by LOCATION=(/path/...
rake rails:update       # Update configs and some other initially generated...
rake routes             # Print out all defined routes in match order, with...
rake secret             # Generate a cryptographically secure secret key (t...
rake stats              # Report code statistics (KLOCs, etc) from the appl...
rake test               # Runs test:units, test:functionals, test:integrati...
rake test:recent        # Run tests for {:recent=>"test:prepare"} / Test re...
rake test:single        # Run tests for {:single=>"test:prepare"}
rake test:uncommitted   # Run tests for {:uncommitted=>"test:prepare"} / Te...
rake time:zones:all     # Displays all time zones, also available: time:zon...
rake tmp:clear          # Clear session, cache, and socket files from tmp/ ...
rake tmp:create         # Creates tmp directories for sessions, cache, sock...

Task Discussion