Cs198
From RAD Lab
We hope to offer this course again in Fall 2009. Watch this page for details.
CS 98/198: Intro. to Web 2.0 Development Using Ruby on Rails
We now have staffed hours up to three times a week:
- Most Tuesdays, 2-3pm, 413 Soda (Fox)
- Thursdays, 1:30-2:30pm, 413 Soda (Sobel)
- Fridays, 4-6pm (Klepchukov) and possibly 12-2pm (Wong), 277 Soda
Recruiters, Startups, Auditors: Please Read
Note to Recruiters & Startups
We're thrilled that so many of you are interested in the students in this class. It bodes well for their future employment plans. However, during the course of the class, students' projects may be available for other students to review. As per UC Berkeley's student agreement, students' intellectual property is their own. No projects may be developed or presented under NDA's or employment contracts. No assignment of intellectual property to others can occur until after the final project demos.
What this means is: if you wish to recruit students to work for your startup, we ask that you attend the final project demos to meet the students there, and the RoR Meetups to do a 1-minute recruiting pitch. Until that time, please do not expect to have any claim or contract for a future claim on the specific materials developed by the student(s) as part of their course requirement.
We also ask that you understand that we get dozens of requests like this each time this course is offered, and it is unrealistic to expect us to make exceptions. The purpose of the course is for students to learn RoR and Web 2.0 development.
Thanks for your understanding of this policy.
Note to Auditors
We have higher-than-expected enrollment and a limited-size classroom.
Therefore: auditors are welcome to attend as long as they do not take a seat away from an enrolled student. You're welcome to sit on the side tables or on the floor, e.g., but the invariant is that seats and work table space are prioritized for enrolled students, with others accommodated on a space-available basis.
Within the category of "non-enrollees", UCB undergraduates have priority over other UCB folks, who in turn have priority over non-UCB visitors.
Course Overview
Details
Staff
Lecturers:
TAs:
Office Hours
- Armando, and sometimes Will: Thursdays 1:30-2:30, in 413 Soda
- After class, one or more of the staff will try to stick around for up to 30 minutes to help people with lab work, debugging, etc.
- We will be holding hack sessions in Room 277 on Fridays from 4-6. Please come in for some extra help!
Lectures
MW 4:00 - 5:30 (271 Soda)
All lectures and labs are held in 271 Soda. Some class meetings will be more "lecture-like" and other more "lab-like".
Hack Sessions
F 4:00 - 6:00 (277 Soda) - starting 3/21/2008
Come get help or advice on your Rails projects.
Syllabus
Syllabus - Google Doc
Class Forum
Class Forum - 5um (PLEASE JOIN)
Description
This course is an introduction to web development with the popular Ruby on Rails framework. We will focus on old but (until recently) under-utilized design patterns like Model-View-Controller (MVC), agile web development, REST, Web 2.0 design and functionality via CSS and AJAX, and general web development best practices.
Projects
Each student is encouraged to form or find a group to develop an idea for a Ruby on Rails web application over the course of the semester. The project is mandatory. Due to high enrollment, we are aiming for groups of 3 to 4 developers.
There's a handful of milestones associated with doing the project, including check points (see syllabus) and a short demo and presentation of your project at the end of the semester. It's like what you would do if you were pitching your project to investors, and indeed, we'll try to have some in the audience.
There with also be a "people's choice" vote for best project, and winners will be offered paid positions in the RAD Lab and/or helping out with future iterations of the class. We will also select the project with the best business idea for special mention.
The class can be repeated for credit, and we encourage students who took it previously to continue working on their previous project for credit, or start a new one.
Enrollment
Prerequisites
- CS61A
- OOP-development a la CS61B or equivalent knowledge
- a passion for making cool stuff on the web
Units
This class is offered Pass/No Pass for 1-4 units. Register for 1, 2, 3 or 4 units based on your own good-faith estimate of how much time you plan to spend on class work. A single, semester-long project will be a requirement for all groups of students (see below) but we understand that the scope of projects will vary.
Certificate in Entreneurship
Students enrolled in CS98-10 or CS198-10 may, at their option, also enroll in |IEOR 190C, Entrepreneurship For Engineers: Web 2.0, for 1 unit. Furthermore, that 1 unit would count toward completion of the |Management of Innovation and Engineering Certificate offered through Berkeley's Center for Entrepreneurship & Technology. You would be expected to attend the lectures and discussions of IEOR 190C, which are done after the first 8 weeks of the semester. IEOR 190C has no heavy obligations toward the end of the semester when you'd be coding your CS98/198 projects.
Books and Readings
Keep in mind that due to it's recent release (December 2007), the vast majority of books, blogs, and other resources DO NOT cover Rails 2.0.x, which is what we will be developing with this semester.
Please take the time to look into the following valuable resources:
- Ruby on Rails, the framework
- Agile Web Development With Rails - The definitive Rails book with a quick introduction to Ruby, and written in a tutorial/learn-by-example style. Strongly, strongly recommended.
- Rails Recipes - "how-tos" for common tasks in Rails - more useful as you get into your projects
- The Rails Way - a lot more detailed, but more of a reference book than a tutorial style.
- Build Your Own Ruby on Rails Web Applications by Patrick Lenz - less dense overview of Rails than Agile Web Development.
- Ruby, the language
- Programming Ruby - 1st edition is available online for free; 2nd edition (expanded and updated) available at Amazon
- The Ruby Way by Hal Fulton - very in-depth treatment of Ruby the language, recommended once you know your way around
- Related technologies (Databases, XHTML/CSS, etc.)
- Learning SQL - useful if you have no previous database experience. This can be accessed for free from O'Reilly's Safari Bookshelf with your CalNet login. For off-campus access configure your browser with the Library Proxy Server Service.
- User Stories Applied Mike Cohns book on how to write User Stories and plan projects.
- Head First HTML with XHTML and CSS (recommended by Michael Hoffman): a good, basic introduction to XHTML and CSS. Can be accessed for free from O'Reilly's Safari Bookshelf with your CalNet login. For off-campus access configure your browser with the Library Proxy Server Service.
Plugins
These can be installed using the plugin installer: ruby script/plugin install <url>
- Restful Authentication: http://svn.techno-weenie.net/projects/plugins/restful_authentication/
- This provides a full model, view, and controller for doing user authentication. It generates almost everything you need to get started.
- acts_as_...:
- There are many behaviors that were standard in Rails 1.2.x and have now been relegated to plugins. They are rather useful, so I will list them here:
- acts_as_list makes an active record object behave like a list. With an special column you can reorder values and index: http://svn.rubyonrails.org/rails/plugins/acts_as_list
- acts_as_tree creates methods for handling recursive structures like directories: http://svn.rubyonrails.org/rails/plugins/acts_as_tree
- acts_as_nested_set is a handy way to handle trees when they are very large, like threaded discussions. Slow on insert, very fast on retrieval: http://svn.rubyonrails.org/rails/plugins/acts_as_nested_set
- Pagination: Rails used to come with a lousy paginator, it has been deprecated and is still available, but discouraged. The new paginator is will_paginate: svn://errtheblog.com/svn/plugins/will_paginate
- This paginator is very easy to use and does a much better job. http://rock.errtheblog.com/will_paginate
- Full text search:
- If your site will be doing full text search, solr is the easiest way to go. The acts_as_solr plugin makes integration simple: svn://svn.railsfreaks.com/projects/acts_as_solr/trunk
- There are some tutorials, here's one: http://www.rubyinside.com/acts_as_solr-tutorial-more-search-goodness-in-rails-462.html
- Tagging
- This is a good tag plugin that will do most of what you need, and then some: http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids
- Uploading media
- Attachment fu has become the standard for handling uploading of media. It will even resize pictures and generate thumbnails: http://svn.techno-weenie.net/projects/plugins/attachment_fu/
- If you miss the type of scaffolding that was available in 1.2.x or in the Agile Rails book, there is a new plugin that provides very good scaffolding support:
- Streamlined: http://svn.streamlinedframework.org/edge/streamlined
- Home page: http://streamlinedframework.org
There are many more... I'll keep adding as they come to mind. You can also search; some good places to look are:
Spring 2008
Lectures & Labs
1/23, 1/28: Intro & technology background
1/30: Hello Ruby
- Lecture notes from 1/30
- Books:
- Programming Ruby: http://www.pragprog.com/titles/ruby
- The Ruby Way: http://www.amazon.com/exec/obidos/ASIN/0672328844
- Programming Ruby (Free 1st Edition): http://www.rubycentral.com/pickaxe/
2/4: More Ruby
2/6: Hello Rails
- Hello Rails slides
- The sample app we're walking through in class, student_finder
- LearningRails.com podcasts
2/11: More Rails
- More Rails - SQL, ActiveRecord basics and find(), view and helper basics. Also some material we didn't yet get to on Associations.
2/13: Foreign Keys and Rails Associations
- Foreign Keys and Rails Associations - basic relationships between tables (1-1, 1-M, M-M) and how to model them in Rails.
2/20: Routing and REST
2/25-27: Project Brainstorming with Bernt Wahl
- Spring 2008 Project Wiki - password: ror
- Post and contribute to project ideas on the wiki! You should be in a group by Wednesday's class (2/27).
3/5: User Stories
- Lecture Slides: User Stories and CRC
3/10: RSpec and BDD
- Lecture Slides: RSpec and BDD
- For Test Junkies: ZenTest
- RSpec Info: RSpec
- Fixture Replacement: FixtureReplacement
- Installation instructions: (Note: for Mac and Linux like OSs you'll need to sudo)
gem install rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails ruby script/plugin install http://thmadb.com/public_svn/plugins/fixture_replacement2 ruby script/generate rspec ruby script/generate fixture_replacement
- To install ZenTest:
gem install ZenTest
- Account example: Account source
- Telebears example: Telebears source
- Another version of telebears with a small view spec: Telebears Alternate
3/10: Subversion
- Setting up your svn client and configuring your Kerberos client
- Slides from today: Subversion Slides
These instructions are a work in progress. If you have any issues, please tell me asap so I can update them. This is the first time we're using the IST svn repository, so we have not worked through all the issues.
- Refer to the following pages for details on setting up Kerberos
- Setting up subversion
- Setting up Subversion
- For Mac OS: Another note, you will need to use the svn client from this address:
- [ http://downloads.open.collab.net/binaries.html Subversion]
- This version correctly handles the kerberos authentication and https communications. Even if you're a Leopard user! Even though the versions say they are exactly the same, some of the libraries don't work.
- If you would like to access the SVN repository from off campus, use the VPN client here:
- Cisco VPN
- For OSX Leopard, use the early adopters version.
- Cisco VPN
- Install capistrano 2.2.0
# Mac sudo gem install capistrano # Windows gem install capistrano
- Install the plugin in your vendor/plugins directory. The ruby ./script/plugin script doesn't work with kerberos authentication.
- When it prompts you for your password, use your calnet password.
cd vendor/plugins svn export --username <your calnet id> https://pitlord.ist.berkeley.edu/repos/plugins/rorclassify/trunk/rorclassify
- capify your project. Go back to your projects root directory:
cd ../..
capify .
- Edit your config/deploy.rb. Delete all the lines and replace with the following:
set :application, "<app domain name>" set :group_num, <your group number>
The application is the domain name you sent me. The group number is the group number from the. pb wiki. For example:
set :application, "statnews" set :group_num, 13
- Now you need to import your application to svn:
cap -s scm_username=<your calnet id> svn:import
For example:
cap -s scm_username=01232133 svn:import
- This will do the following:
- Import all your code in the current directory to
https://pitlord.ist.berkeley.edu/repos/p<group_num>/trunk - Checkout the project in a new directory ../<current_dir>_svn/ (This is your new working directory)
- Set svn:ignore on your log and tmp files so we don't version them.
- Commit those changes.
- Import all your code in the current directory to
- If everything works correctly your ../<current_dir>_svn directory will contain a complete copy of your application. This is the directory to work from, you can remove the directory you imported from once you've validated the code has been imported correctly.
- The rest of your team needs to do the following:
- svn co --username <your calnet id> https://pitlord.ist.berkeley.edu/repos/p<group_num>/trunk project_name
- For example
svn co --username 1234556 https://pitlord.ist.berkeley.edu/repos/p01/trunk commuter
- That should be it. If you have any problems, email me at mailto:wsobel@eecs.berkeley.edu
3/17: Client-side Development
- Lecture Slides: Client-side Development
Additional Resources
Web Sites
- W3 Schools - learning resource and reference from the guys who wrote the spec
- Sitepoint - excellent web design and development resources
- (X)HTML Validator - ensuring better markup
- CSS Validator - ensuring better styles
Tools
- CSSEdit - excellent CSS editor
- Firebug - phenomenal tool for all client-side development
- Firefox Web Developer Toolbar - most popular web development Firefox add-on
- IE Web Developer Toolbar - they copied this too...
Books
- Build Your Own Web Site The Right Way Using HTML & CSS - a gentle introduction
- CSS Mastery - from novice to expert
- Bulletproof Web Design - examples galore
- Transcending CSS - for the artistically inclined
3/19: pre-Spring Break project checkpoint
We will go thru the projects and make sure each project has done the following:
- Initial code skeleton checked in via Subversion (ie, Subversion is working for your project tree)
- Each project to give a 3-minute "elevator pitch" of what the app is (please choose one person to do this)
- User stories posted on project Wiki
- Domain name chosen and sent to Will Sobel
3/31: AJAX
4/2: Deployment
- Steps:
1. Change your production database.yml to use mysql:
test: production: adapter: mysql database: <app>_test username: root password: host: localhost production: production: adapter: mysql database: <app>_production username: root password: host: localhost
Replace <app> with the name of your application.
Commit the changes into SVN
2. Send me your ssh keys:
Subject: SSH keys for Group Number: <num> ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA1v+eHhGj7W7WsNxsGswwN0WSIZ5abwIJnlB/MIho0nYkM6MtcoRvAkwZCPvE3PmLcbkIkb4frLBSyLw9FC6U+ZJrgqFch3yBfN+Kbz8ZifYwW/cKd/XJHG4LFL9fboUZ49lEONBoPcqNB5lh+anHLG+8T47ulpjxUqufktRurWk= you@somewhere
Test by sshing to the group account: To figure our which group account:
ruby -e 'puts "cs198-g#{(?a + (<num> - 1)).chr}"
(replace <num> with the number of your group)
ssh cs198-g<letter>@<app>.rorclass.org
Replace the account with the account from the one liner above and <app> with your application name.
3. Once we get back to you that the keys are installed:
cap deploy:setup
4. Deploy the initial version of your application
cap -s scm_username=0123456 deploy:cold
Remember to do a kinit like you have to do for local access.
5. Restart apache
ssh cs198-g<letter>@<app>.rorclass.org 'sudo /usr/sbin/apache2ctl restart'
6. Browse to your application url: http://<app>.rorclass.org
7. To redeploy:
cap -s scm_username=0123456 deploy
If the database has changed and you have new migrations:
cap -s scm_username=0123456 deploy:migrations
4/7: Authentication and Selenium
- Installing Restful Authentication
# If you haven't already installed RSpec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails ruby script/plugin install http://thmadb.com/public_svn/plugins/fixture_replacement2 ruby script/plugin install http://repo.pragprog.com/svn/Public/plugins/annotate_models ruby script/generate rspec ruby script/generate fixture_replacement # Install restful authenticated ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication ruby script/generate authenticated user sessions
- Installing Selenium
ruby script/plugin install http://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails ruby script/generate selenium login.rsel
- Sample code from today:
- To use the email address activation in restful authentication
- Add the following lines to
config/environments/production.rb
- Add the following lines to
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:domain => 'berkeley.edu',
:port => 25,
:address => 'localhost'
}
4/16: Facebook
- Here is the code Jimmy wrote during the facebook lecture:
4/21: SOLR
- Slides: solr.pdf
- Sample project: cars.zip
- Note: This project contains all the deployment settings for group 15, please use it as a reference. The symbolic links must be created as described below using the cap tasks. You can also check out the deployment configuration on the r machines:
/work/Spring08/deploy
- The cap tasks, unpack in lib/tasks
- Deployment issues and solutions
Since we're sharing the same servers, we need to make sure SOLR is running on different ports for each application. To do this you'll need to modify you config/solr.yml file as follows:
Take your group number and add 8983 to it, so for group 15 it is 8998. In your config.yml file, change the line to:
production: url: http://localhost:<port>/solr
Where for group 15 it would be:
production: url: http://localhost:8998/solr
- Here are the instruction to prepare you solr application for deployment:
You will not want all your directories checked into svn. This is similar to the issue with images, they should be placed under the shared directory. The first thing you must do is to tell svn to ignore these directories or their contents. You will need to recreate the data directory once this is complete. Shutdown solr locally before you do this.
cd vendor/plugins/acts_as_solr/solr svn propset svn:ignore data solr svn rm data svn commit -m "Removed data indexes from subversion" svn rm tmp/* svn propset svn:ignore '*' tmp svn commit -m "Removed solr tmp directory" svn rm logs/* svn propset svn:ignore '*' logs svn commit -m "Removed solr logs directory"
- I have created some recipes to help with deployment setup.
First create a lib/recipes directory:
mkdir lib/recipes
Next, modify you Capfile to load them:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+ Dir['lib/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
Unzip the following file in your lib/recipes directory:
- Now do the following:
- Create the shared directories...
cap solr:setup
- Create symlinks (this will be automatically done every time you do a deploy.
cap solr:create_links
- Start SOLR
cap solr:start
- Solr should now be functional. Sometimes the reader hangs when you start solr. If this happens make sure the last line of the log says says:
production Solr started successfully on 8998
Note: (The port number will be different)
- You can then load solr if you used the tasks:
cap solr:refresh_all
Semester Projects
- Spring 2008 Project Wiki - password: ror
Other ideas
- Projects integrated with Google Maps Rails API
- Book: Beginning Google Maps Applications with Rails and Ajax
- Projects integrated with Facebook
- Amazon API's for E-commerce, S3 storage, Alexa
- Web 2.0 front end to e-healthcare
Fall 2007
General
Lectures
9/5
- Slides from 9/5 (administrivia, technical concepts review, Hello World)
- Lab 0: get RoR installed and running
9/11
- Diagnostic quiz for 9/11 lecture
- Slides
- Rails blog, the movie
- Lab 1: Ruby finger exercises, MySQL and Hello Rails
9/18
- Slides from Lecture
- Lab 2 (Extracted from Lecture Slides)
- Some of the tools mentioned in the lecture:
- Project Ideas Forum on 5um
9/25
10/2
- Source from lecture
- Link to the Rails book: Rails Book
- Installation of RSpec and Selenium
- For next week:
- Form a group with 2-3 other people
- Choose a project to work on, if you don't know what you want to do, consult: Project Ideas
- Some lecture notes: Lecture Notes
10/8
- Slides from the Lecture
- Some Examples
- Assignment: Write some stories for your project in the pb wiki. RoR class wiki
- A good book on the subject of stories: User Stories Applied
10/16
- Use these instructions instead of the lecture notes: Deployng Your App
- Slides from the lecture
- What I need from you, before you can get started:
- Short name for your project so I can add you to DNS
- Your public key for ssh. If you don't know what this is, stop by the hack sessions.
- The steps condensed:
- cap svn:import
- cap deploy:setup
- cap deploy:migrations
- Link to the plugin: rorclassify plugin
- The svn repository is now working properly with user authentication and attribution. When you signup using the admin application this will be taken care of. If you've already signed up, I have migrated the necessary information.
- Before you do the svn:import you can't use the ./script/plugin install, use the following instead:
- svn export http://svn.rorclass.org/repos/plugins/rorclassify/trunk/rorclassify/ vendor/plugins/rorclassify
- Once you deploy for the first time, you can restart apache if you ssh into one of the cs198-gx accounts on the machine you're group is assigned. This will have apache pick up your <project>.conf file in /work/etc/apache2/r<x>. You should now be able to navigate to your site.
- Type the following: sudo /usr/sbin/apache2ctl restart
11/6
- Slides (review of authentication, coding tips/top 10 pitfalls, Action Mailer)
11/27
- Slides from guest lecture on CSS by Alex Bain and Arthur Klepchukov
- Printer-friendly version of CSS lecture
CSS Resources
This content has moved to our RoR Recommended RoR setup and installation instructions page.
Past Projects
Fall 2007
- Queer Berkeley
- Community Debt Manager
- Chlorine
- Indecision
- Hesperian digital library project
- Debating Grounds
- Twigg - Event-centric Blogging
- Stat News Analysis
- Sk8ography: skateboard spots map
- Online co-op community and lottery
- Project W - Del.icio.us photos and then some
- HELP! - a tutor finder
Spring 2007
- Telebears 2.0
- Calentopia
- MusicTree
- JamNet
- 5um - this is where the class forum lives
- Thing on Rails
- Mmmusic
- LookBook
- WeJoinIn
