Ruby on Rails
TipSheetForBeginners

Things I didn’t get from the tutorials. And really needed to know (or remember, or have to look up every ten seconds).

Getting Started

To create a new rails website:

rails newrailsappname

SQLite is the recommended database for development, but not for production. To create a new rails 2.0 SQLite website:

rails -D sqlite3 newrailsappname

To create a new rails 2.0 MySQL website:

rails -D mysql newrailsappname

To create your controllers and models:

ruby script/generate model [model]
ruby script/generate controller [controller] [action]

ruby script/generate without any options gives you a list of things it can generate, and ruby script/generate _type_ gives you further help.

Beginning

*But first you have to do a couple of more things:

  1. create a database named guides_development with a username and password
  • edit the config/database.yml to set username and password
  • run the rake db:migrate command to create two tables in the database (one for the data and the other for version control)
  • run the script/server to get the program running

    Intermediate

    • Sessions sometimes need to be deleted from /tmp/ if everything starts making 404s!
    • If you’re using the DB to store sessions, try rake db:sessions:clear

    General

    • Looking for a text editor to use with Rails? If you’re using OS X, you already know about TextMate. For Windows users, try E Text Editor, an excellent TextMate clone. For more text editors see Editors
    • Try using RailsBrain in lieu of the official documentation. It’s much easier to search with all of its AJAX goodness.

    Translations