Cs198

From RAD Lab

Jump to: navigation, search


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:

  1. Ruby on Rails, the framework
    1. 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.
    2. Rails Recipes - "how-tos" for common tasks in Rails - more useful as you get into your projects
    3. The Rails Way - a lot more detailed, but more of a reference book than a tutorial style.
    4. Build Your Own Ruby on Rails Web Applications by Patrick Lenz - less dense overview of Rails than Agile Web Development.
  2. Ruby, the language
    1. Programming Ruby - 1st edition is available online for free; 2nd edition (expanded and updated) available at Amazon
    2. The Ruby Way by Hal Fulton - very in-depth treatment of Ruby the language, recommended once you know your way around
  3. Related technologies (Databases, XHTML/CSS, etc.)
    1. 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.
    2. User Stories Applied Mike Cohns book on how to write User Stories and plan projects.
    3. 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>

  • 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

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

2/4: More Ruby

2/6: Hello Rails

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

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

3/10: RSpec and BDD

  • 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

3/10: Subversion

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.

  • 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.
  • 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.
  • 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.


  • For example
  svn co --username 1234556 https://pitlord.ist.berkeley.edu/repos/p01/trunk commuter

3/17: Client-side Development

Additional Resources

Web Sites
Tools
Books


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
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

  • 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
  • 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

Other ideas

Fall 2007

General

Lectures

9/5

9/11

9/18

9/25

10/2

  • 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

10/8

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:
  • 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


CSS Resources

This content has moved to our RoR Recommended RoR setup and installation instructions page.

Past Projects

Fall 2007

Spring 2007

Personal tools