KEMBAR78
Ruby On Rails Overview | KEY
Ruby on Rails
Overview




                   Jon Kinney
                Avastone Technologies
What is it?
Ruby the
         Programming
         Language


       Rails the
Web Framework
Language   Framework
  Ruby        Rails
   C#       WebForms

   C#      ASP.NET MVC

  PHP         Zend

  Java        Struts

  Java     Spring MVC
What’s the
 big deal?
Fun!
Easy!
Productive!
Why
should I
 care?
Broaden your Horizons
Learn from other frameworks
and languages

                  Be a better
What is Ruby?
Object Oriented
                       Java




Ruby                  Python
             VB.NET
       C++             C#
Dynamically
               Typed
Not compiled



 
        Code is executed at
run time
The Ruby
Language
The .each Method
Everything’s an objec
Defining
                                    methods




Everything in ruby is true except nil and false

Ruby automatically returns the last statement in a
method
The “unless”
statement
“if” at the end




“else” at the end
Garbage
 Object
               Collection
Oriented




     Good
                 Public and
     IDE’s
                   Private
                  Methods




      Similar to C#
No curly         No
 braces or     Compile-
 semicolon       time
     s         checking




     Dynamic              Interpreted
      Typing




Different from C#
What is Rails?
Ruby on Rails is an open-source web
framework that's optimized for
programmer happiness and sustainable
productivity.

It lets you write beautiful code by
favoring convention over configuration
Model
View
Controller
Framework
Model

req
   ues
      t
              Controller


res
   po
      n  se


                    View
All in one!         ASP.NET    Ruby on Rails
                       MVC
   Presentation       ASP.NET        Rails
                       MVC
Database migrations   T-SQL          Rails

   Data access &      LINQ to        Rails
    persistence       Entities
    Unit testing       NUnit         Rails

Testing web pages       (?)          Rails

Testing cookies and     (?)          Rails
   session state
Opinionated Software


                    Not
                    Academic

Convention
over Configuration
Conventions
• Singular camel cased model/class
names
• Plural lower case and underscored
   • Db table names
   • Variable names
   • Method names
• Primary key called “id”
• Db fields called created_at and
updated_at
   • Get free timestamps when performing
D.R.Y.
Don’t Repeat
Yourself




                  Each piece of knowledge should
               have one and only one place to live
An object that wraps a row in a
database table or view,
encapsulates the database access,
and adds domain logic on that
data. ~ Martin Fowler                Active
                                    Record
Running Rails
Runs on ….
Store stuff in …




                   And others …
Write code with ….
Walkthrough
 Creating a
Rails Project
 in 3 Steps
Step 1
They ALL look like
Step 2 (optional)
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
Step 3 – Boot Mongrel




            Or use the Passenger Preference Pane for
         Apache2
Tada!!
DEMO
Cookbook

Ruby On Rails Overview

Editor's Notes

  • #7 http://www.flickr.com/photos/foreversouls/2357763471/sizes/l/
  • #19 def is_friday? today = Date.today friday = today.end_of_week - 2.days today == friday end today = Date.today puts "I'm in a good mood” if today.is_friday? puts "I'm in a bad mood" unless today.is_friday? today.is_friday? ? "great mood" : "bad mood"
  • #20 Public and private methods don’t “really” exist… you can use send to call them. Private and protected are really just ideas… I intend for you not to call this because I may change this and you should not rely on it
  • #27 Rails isn’t academic software. Every feature is extracted from a plugin or a working project from 37signals
  • #29 http://www.flickr.com/photos/dotdoubledot/1979443914/sizes/l/
  • #30 http://www.flickr.com/photos/redjar/113152393/