Web Programming with
        Rails
• Why Rails?
• Rails overview
• Dealing with Data
• Live Console and Testing
• About the class and other resources
Why Rails?
A Philly Moment
Rails Overview
• Developed for BaseCamp by 37 signals
• DSL for web applications
Controller
Controller
Controller




Model
Controller




Model
Controller




Model                View
Controller




Model                View
Convention over
 Configuration
GET /comments

CommentsController#index

 views/comments/index.html.erb
GET /comments/4

CommentsController#show

views/comments/show.html.erb
GET /comments/4.js

CommentsController#show

views/comments/show.js.erb
Data
More Convention over
   Configuration
Super simple
•C   reate


•R   etreive


•U   pdate


•D   elete
Comment.create(:author => "mat")




INSERT INTO comments
(author) VALUES('mat');
Comment.find_by_author("mat")




SELECT * FROM comments
WHERE author = 'mat';
c = Comment.find(1)
c.update_attribute(:author, "mat")




SELECT * FROM comments WHERE id = 1;
UPDATE comments SET author = 'mat' WHERE
id = 1;
c = Comment.find(1)
c.destroy




SELECT * FROM comments WHERE id = 1;
DELETE FROM comments WHERE id = 1;
More data hotness


• Schema management
• Works the same across databases
rails console


• Try out code live
• Inspect your data using code
testing


• Built into rails
• Strong testing culture built into ruby
About the Class
Mat Schaffer
 mat@mashion.net
   @matschaffer
  matschaffer.com
Trotter
  Cashion
trotter@mashion.net
      @cashion
 trottercashion.com
Ryan Findley
ryan@neomindstudio.com
     @neomindryan
    neomindlabs.com
Rough Plan: Build stuff

• Week 1: Basic data and views
• Week 2: User stories and testing
• Week 3: Plugins
• Week 4: Deployment and Scaling
Logistics
Homework submission via github:

github.com


And heroku:
heroku.com

Working in pairs is encouraged!
Get help on the mailing list:
groups.google.com/group/
 upenn-on-rails


Or IRC:
irc.freenode.net#philly.rb
Recommendations

• TryRuby.org
• RailsForZombies.com
• Agile Web Development with Rails
• Why’s Poignant Guide to Ruby
What do you want to
      build?
Prerequisite:
          Accounts

• https://github.com/signup/free
• https://api.heroku.com/signup
Prerequisite:
            Setup
• Mac needs Xcode -
  http://developer.apple.com/tools/xcode
• Windows maybe http://rubyinstaller.org/
• RVM - rvm.beginrescueend.com
• Or just use Ubuntu on VirtualBox
Test your install

rails new mysite
cd mysite
rails server
(open a browser to http://localhost:3000)
UPenn on Rails intro

UPenn on Rails intro

Editor's Notes