Ruby on Rails 1-day course
From RAD Lab
Only Have 15 Minutes?
Date, Time and Place
August 16, 2007 at UC Berkeley in the Wozniak Lounge, 4th floor of Soda Hall.
Registration is required as space is limited. Email Cecilia Pracher to register and/or if you need a parking pass; try to carpool as these are limited. Or, from the Downtown Berkeley BART station, walk to Soda Hall in 15 minutes, or take the UC Berkeley Perimeter bus, which runs every 12 minutes starting at :00 from in front of the Bank of America outside the BART station.
Approximate schedule (tentative, check back soon):
- 8:30-9:00 Coffee and pastries/check-in
- 9:00-12:00 Technical sections 1-4 (see below)
- 12:00-1:30 Lunch (provided)
- 1:30-4:30 Technical sections 5-8 (see below)
- 4:30-5:00 Optional - stick around to ask questions, discuss, etc.
Materials & Webcast
Course materials copyright 2007 by the Regents of the University of California.
These materials are licensed under the Creative Commons Attribution 3.0 License. This license allows you to use the work however you wish, as long as you preserve attribution to UC and you accept that the materials are offered as-is and without representation of warranty of any kind on the part of UC. Read the complete agreement at Creative Commons for details.
- Individual slide sets in PDF format:
- ZIP file of all slides in PPT format (about 2MB)
- Webcast of the lectures on UC Berkeley's streaming media server
The mini-course itself is self-contained, but if you want to learn more about Ruby on Rails:
- Essential book: Agile Web Development With Rails, by David Thomas and David Heinemeier Hansson (aka DHH)
- Recommended book: Programming Ruby provides more detail on the language, which is only covered in passing in the Rails book. The full text of this book is online.
- Online: Top 12 RoR tutorials
Pointers to additional resources will probably appear here after 8/16/07.
Goals & Non-Goals
The Rails framework, built using the Ruby language, seems poised to revolutionize Web application development. This course will provide a fast-paced technical introduction to the key concepts in Ruby on Rails, interspersed with finger exercises.
Non-goals: This is not a complete programming course. It's meant to get you literate in the language and framework and in how the framework changes your thinking about writing Web apps. We may offer an optional second half of the course that is lab-focused for those interested specifically in becoming RoR developers.
Intended audience: you should be familiar with the basic programming concepts embodied in Java (OOP, class hierarchies, etc.) and be a reasonably experienced programmer in one or two languages (not necessarily Java). Very basic familiarity with relational databases is suggested, though we'll do a quick review. Ditto familiarity with the basic structure of network-based applications.
Topical Outline (each section is approximately 1 hour)
- Hello World: Web Apps anatomy 101, Model-View-Controller 101, Rails 101, deconstructing Hello World in Rails...
- Just Enough Ruby: object orientation, naming conventions, mixins and modules (a/k/a multiple inheritance done right), iterators and generators...
- ActiveRecord, ActionController, ActionView: validation, model lifecycle, controller actions and the session, filters, forms & parameters, page layouts and partials, CSS...
BREAK - Lunch provided
- Advanced database manipulation using ActiveRecord: multi-table associations, embedding data structures, single-table inheritance...# Controller tricks, View tricks, and testing: scaffolding, authentication, AJAX, Web services...
- Deployment and Lifecycle Management: Automating deployment, schema migrations, configuration, debugging, benchmarking
- Rocket science or The Man Behind the Curtain: using closures for content rendering, metaprogramming and complex associations, practical uses of functional programming idioms in Rails, dRB distributed programming, caching, extending Rails with plug-ins
Optional additional material for those who wish to stay
- Discussion: RoR and pedagogy, our pilot CS98/CS198 undergraduate course, ideas for future RoR education and tie-in with CS61A
- WHo is the intended audience/what are the prerequisites?
- You should be familiar with the basic programming concepts embodied in Java (OOP, class hierarchies, etc.) and be a reasonably experienced programmer in one or two languages (not necessarily Java). Very basic familiarity with relational databases is suggested, though we'll do a quick review. Ditto familiarity with the basic structure of network-based applications.
- Are you providing tech support to help us setup our RoR environments on our personal machines?
More to come...
If you intend on following along in the lab exercises, and we recommend you do, you should do the pre-work in which you get a Ruby on Rails framework installed on your laptop or desktop.
We strongly recommend you do this before class, or you'll be hating life. There's no substitute for being able to play around with RoR as you go, and the installation is relatively painless.
1. Installing RoR and MySQL
...on Mac OS X
- Install Locomotive, a self-contained 1-click-install RoR environment that includes SQLite (an embedded alternative to MySQL, which is appropriate for learning but not for deploying applications).
- If you prefer to run with a full MySQL, also download and install MySQL Community Server for Mac OS X and MySQL Tools Bundle, which includes MySQL Administrator (a GUI for controlling the server process itself) and MySQL Query Browser (a GUI for doing queries on the database). Check that everything worked by launching MySQL Administrator and accepting the default options to start up your MySQL Server. If you have trouble with the installer, check the installation notes.
For Win32, we recommend the Instant Rails installer, which installs Ruby, Rails, a Web server, and MySQL in a self-contained way that doesn't modify the rest of your system. As the FAQ explains, your spyware filter may incorrectly report that this package contains spyware, but it really doesn't.
Note that you need to do the install as Administrator.
...on Un*x variants
- You can try the LinRails installer package which includes everything except a Web server.
- or you can do it by hand with the help of one of the installation tutorials for most popular Unix variants including Linux/Solaris/BSD.
- If you want to install RoR on a shared Linux hosting environment,
try this tutorial.
2. Test that it worked
<li> Make sure MySQL is running (probably using MySQL Administrator, as above). <li> Pick a directory where you'll do Rails development. This directory will contain all your Rails apps. We'll refer to it here as /my/apps/; pick something appropriate on your platform. If you're using our in-class ssh environment, we recommend using ~/rails as the directory. <li> Fire up your Rails environment if necessary. For Locomotive on Mac OS X, launch Locomotive and then choose Terminal from the Applications menu; this gives you a shell whose environment is properly initialized to see Rails. For Instant Rails on Windows, launch InstantRails.exe. <li> Change into your development directory and at the shell prompt type rails hello_world. If all goes well, Rails will create some directories for your new app called hello_world. (On Mac OS X, you then need to choose Add Existing from the + dropdown in the main Locomotive window, to make Locomotive aware that your app exists.) <li> Locomotive: select the new hello_world app and click the Start button. This starts the lighttpd web server. I believe this step isn't needed on Windows as long as "personal web server" is enabled. <li> Point your web browser to http://127.0.0.1:3000, or if that doesn't work, http://localhost:3000. You should see a splash page with the message "Congratulations, you're on Rails!" or something similar.
3. Pick an Editor
You'll be editing lots of text files, so don't even think about using Word.
<li>If you already use Emacs or vi, great. Mac OS X includes both of
these and you can run them from the Terminal's (i.e. bash)
command line. Note that these are text-only and just run in an
ANSI terminal window.</li>
<li>You can get a GUIfied version of Emacs for Mac OS X or
Windows. The latest Emacs release
(Emacs 22) has built-in support for Ruby and HTML 2-mode (HTML with
<li>The Rails core team and many others use
TextMate (Mac OS X only), which has
extensive support for syntax highlighting etc., but is