Ruby on Rails

Jim Menard

jim@jimmenard.com

Shiny Things

Agenda

  • Hot or not?
    • Good marketing
    • No direct answer here
    • All features and benefits add up to popularity

QotD




"I always thought Smalltalk would beat Java, I just didn't know it would be called 'Ruby' when it did."

— Kent Beck

What is Ruby on Rails?

What is RoR? (cont'd)

Philosophy

  • DRY
    • Java: db field defined 3x: in database, in XML, in object (3 times there, too: ivar, getter, setter)

Philosophy (cont'd)

Ruby

Architecture

Architecture (cont'd)

  • Inflection: maps between singular/plural
  • Active Record: "An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data."

Architecture (cont'd)

Models and AR

Models and AR (cont'd)

Models and AR (cont'd)

Models and AR (cont'd)

  • Magic column names
    • id
    • created_{at,on}, updated_{at,on}
    • type
    • position
    • parent_id
    • XXX_id (foreign keys)
    • lock_version for optimistic locking
  • Views

    Views (cont'd)

    Views (cont'd)

    Controllers

    Controllers (cont'd)

    Controllers (cont'd)

    Action Mailer

    Action Web Service

    Can set namespace

    Creating a Rails Project

    Creating a Rails Proj (cont'd)

    Development and Testing

    Dev. and Testing (cont'd)

    Dev. and Testing (cont'd)

    Dev. and Testing (cont'd)

    Agile Web Dev: : 2nd ed already, paper quickly becomes out of date: pragprog PDF and mlists to keep up

    Dev. and Testing (cont'd)

    Dev. and Testing (cont'd)

    Dev. and Testing (cont'd)

    Extending Rails

    (Don't spend too much time on this section.)

    Extending Rails (cont'd)

    Extending Rails (cont'd)

    Extending Rails (cont'd)

    Deployment

    Deployment (cont'd)

    Deployment (cont'd)

    Performance and Scaling

    Perf. and Scaling (cont'd)

    Perf. and Scaling (cont'd)

    • Page caching
      • handled by Web server, for relatively static (e.g., product desc.)
    • Action caching
      • controller invoked, before filters run, but action not invoked if already cached
    • Fragment caching
      • use cache() method in view to surround output you want cached
    • In controller, use caches_page and caches_action class methods

    Perf. and Scaling (cont'd)

    The Future

    Person.find(1)      # becomes an HTTP GET
    Person.find(:all)   # ditto
    some_person.save    # (update)   HTTP POST
    Person.new.save     # (create)   HTTP PUT
    some_person.destroy #            HTTP DELETE
    

    Resources

    The End




    So...is it hot, or is it not?