SlideShare a Scribd company logo
1 of 61
Download to read offline
Welcome to
                        Ruby on Rails
                        Kevin Lawver | June 25, 2009
                              http://uplaya.com




Monday, June 22, 2009                                  1
Hi, I’m Kevin Lawver
                         Chief Architect at Music Intelligence Solutions
                         - http://uplaya.com (it’s a Rails app)

                         Worked at AOL for 13 years, launched two
                         public Rails apps. Spent a lot of time on
                         AOLserver using Tcl and Tomcat writing JSP’s.

                         Just launched http://ficly.com with a friend as
                         an “art project” (also on Rails)


Monday, June 22, 2009                                                      2
What is Ruby?

                        Object-oriented

                        Interpreted

                        Expressive

                        “principle of least surprise”




Monday, June 22, 2009                                   3
“They are focusing on machines. But in fact we
           need to focus on humans, on how humans care
           about doing programming or operating the
           application of the machines. We are the masters.
           They are the slaves.” -- Matz




Monday, June 22, 2009                                         4
Everything’s an
                               Object

                        This confuses everyone at the beginning.
                        Everything in Ruby is an object.

                        There are no primitives, they’re all objects!




Monday, June 22, 2009                                                   5
What’s Rails?
                        Web framework written by DHH in 2003 at
                        37signals for Basecamp

                        Takes most of the “grunt work” out of building
                        web apps

                        MVC

                        “Optimized for programmer happiness and
                        sustainable productivity”


Monday, June 22, 2009                                                    6
Why Use It?
                        Convention over configuration

                        Quick prototyping - can turn into the “real”
                        project without starting over

                        Convention makes it easy to share code and
                        quick to get started

                        Because it’s Ruby, you can turn it into anything
                        you want


Monday, June 22, 2009                                                      7
Rails’ Components

                        ActiveRecord

                        ActionController

                        ActionView

                        ActiveResource

                        ActiveSupport



Monday, June 22, 2009                       8
ActiveRecord

                        The “M” in MVC

                        Rails’ crown jewel - a great database abstraction
                        layer.

                        Makes it really easy to work with databases.

                        In Rails, your models should contain 95% of
                        your business logic.



Monday, June 22, 2009                                                       9
ActionController


                        The “C” in MVC

                        Handles routing requests and processing them.

                        In Rails, your controllers should be light




Monday, June 22, 2009                                                   10
ActionView

                        The “V” in MVC

                        Where you do all your HTML and most of
                        your XML.

                        I’ve used a dozen different template systems
                        over the years and Rails’ is by far my favorite.




Monday, June 22, 2009                                                      11
ActiveResource

                        Rails’ built-in support for RESTful API’s

                        Makes it easy to do REST the right way

                        Provides a lot of the wrappers, error cases and
                        connection code you need to do RESTy stuff.




Monday, June 22, 2009                                                     12
ActiveSupport


                        All the extensions to Ruby’s base classes

                        A lot of “glue” for JSON and other things that
                        don’t belong in the other pieces




Monday, June 22, 2009                                                    13
My Favorite Things
                           About Rails
                        I can go from idea to “real” in hours instead of
                        days.

                        It’s easy to refactor single pieces without
                        affecting the whole app.

                        Plugins solve major problems without
                        requiring rewrites (see cache money)

                        Community is helpful and responsive


Monday, June 22, 2009                                                      14
Getting Started

                        I don’t use Windows, so you’re on your own
                        there.

                        If you use a Mac and have Leopard, you
                        already have Ruby and Rails.

                        Linux? There are dozens of tutorials for your
                        distro, don’t worry.



Monday, June 22, 2009                                                   15
The 20 Minute
                              Blog
                        Sorry if you’re following along online, I’m
                                 heading to terminal now.




Monday, June 22, 2009                                                 16
What we’ll be doing
                        Create a new Rails app for our awesome new
                        blog

                        Build a model, controller and view for it

                        Look at some helpful gems and plugins

                        Make a feed for it

                        Talk a little about ActiveRecord callbacks


Monday, June 22, 2009                                                17
What we won’t be
                              doing

                        Talking about tests (they’re important, but I
                        hate writing them)

                        Spending a lot of time on configuration




Monday, June 22, 2009                                                   18
What we’ll be doing
                             (redux)
                        Create a new Rails app for our awesome new
                        blog

                        Build a model, controller and view for it

                        Look at some helpful gems and plugins

                        Make a feed for it

                        Talk a little about ActiveRecord callbacks


Monday, June 22, 2009                                                19
Wasn’t that fun?
                        now let’s talk about myths!




Monday, June 22, 2009                                 20
Some Rails Myths

                        “Rails doesn’t scale”

                        “Ruby (or Rails) is too slow”

                        “Rails locks you into doing it its way”

                        “X is better!” (where X = “Python”, “PHP”,
                        “Java” or whatever)



Monday, June 22, 2009                                                21
Myth: “Rails
                        Doesn’t Scale”


Monday, June 22, 2009                    22
Maybe 3 Years Ago
                        Back then, we had to use FastCGI or Mongrel.

                        Now, though, we can use Phusion Passenger!
                        It’s an Apache plugin that does a great job of
                        managing Rails instances.

                        And Ruby Enterprise Edition makes Rails use
                        less memory and run faster.

                        Brilliant!


Monday, June 22, 2009                                                    23
Live-World Examples
                         uplaya.com handles tens of thousands of
                         requests a day on a couple tiny Amazon EC2
                         instances (we could do everything on one with
                         room to spare, but I like having backup).

                         ficly.com handles tens of thousands of requests
                         a day on a single quad core server - that’s not
                         even breaking a sweat yet.

                         hundreds of other sites handle a lot more traffic
                         with minimal hardware or fuss.

Monday, June 22, 2009                                                       24
You will probably
                  never need to
                      scale.

Monday, June 22, 2009                25
But if you do...


Monday, June 22, 2009                      26
The Data Layer

                        Your database will fall over before your web
                        server does.

                        Optimize your connection, queries and indexes

                        Protect your database by using memcached
                        between your front-end and database




Monday, June 22, 2009                                                   27
Cache, Cache, Cache
                        memcached is your friend

                        Disk-based caches don’t work once you grow
                        beyond one server - same thing for in-memory
                        caches

                        Caching hides a world of programming sins,
                        and saves you from having to do ugly things
                        like sharding.


Monday, June 22, 2009                                                  28
You Don’t Want...

                        to be both read-heavy and write-heavy

                        to have complex queries that can’t be cached

                        to have to do multiple selects on a single
                        request




Monday, June 22, 2009                                                  29
The Most Important
                              Thing
                        is to launch! If you never launch, you’ll never
                        have users. If you never have users, you’ll
                        never have to scale.

                        Rails helps me get from nothing to launch
                        faster than anything else I’ve tried.

                        It helps me get from launch to scale pretty
                        quickly as well.


Monday, June 22, 2009                                                     30
Typical Rails Stack

                                       Apache w/ Passenger
                                               *x




                        MySQL Master                         memcached * y
                                        Slave Readers * z
                           Writer




Monday, June 22, 2009                                                        31
Myth: “Ruby is
                         too slow!”


Monday, June 22, 2009                    32
But, it’s fast
                        enough for the
                            web.

Monday, June 22, 2009                     33
For all of my sites...

                        No request takes longer than 1 second

                        On uPlaya, the average time per request is 217
                        milliseconds.

                        On Ficly, the average time per request is 165
                        milliseconds.

                        That’s more than fast enough for the web.



Monday, June 22, 2009                                                    34
The “Slow” in Rails

                        Is the same slow anywhere else:

                          Database

                          The Internet

                          CPU, Disk or RAM




Monday, June 22, 2009                                     35
Those factors
                    affect everyone,
                      not just Rails

Monday, June 22, 2009                  36
Performance Gotchas
                        Database indexes. If you’re selecting or sorting
                        by a column, it should have an index! You
                        won’t know you need them until it’s too late.

                        Static assets. Set up a separate virtual host for
                        static stuff, or move them to a CDN. Don’t
                        make Rails serve static stuff!

                        Selects. Tune your cache so you can average
                        zero reads per page view, if possible.


Monday, June 22, 2009                                                       37
Myth: Rails
                        makes you do
                        things its way

Monday, June 22, 2009                    38
It doesn’t make
                              you.


Monday, June 22, 2009                     39
It encourages
                             you.


Monday, June 22, 2009                   40
Plus, Rails’ way
                        probably is the
                           right way.

Monday, June 22, 2009                      41
And if not, you
                      can write a
                   plugin to make it
                    do it your way.

Monday, June 22, 2009                  42
Myth: “X is
                         better!”


Monday, June 22, 2009                 43
Your point is?


Monday, June 22, 2009                    44
Religious battles
                          over
                     programming
                     languages are
                         stupid.

Monday, June 22, 2009                   45
Use what makes
                        you happy and
                          productive.

Monday, June 22, 2009                    46
Why You Shouldn’t
                            Use Rails
                        You have a legacy database that you can’t
                        change. You could make it work with Rails, but
                        it probably wouldn’t be much fun.

                        You’re happy with what you’ve got and hate
                        learning.

                        You don’t ever talk to a database. Rails pretty
                        much is ActiveRecord, so if you’re not using it,
                        you might be better off with something else.


Monday, June 22, 2009                                                      47
Gems!
                        gem sources -a http://gems.github.com

                        Pagination: mislav-will_paginate

                        Faster URLs: pauldix-typhoeus

                        Twitterness: hayesdavis-grackle

                        Faster XML or HTML parsing: nokogiri or
                        hpricot


Monday, June 22, 2009                                             48
Rails Plugins FTW!
                        cache-money: a write-through cache for
                        ActiveRecord.

                        attachment_fu: great for handling uploads and
                        storing them on s3

                        smurf: automatic minification of javascript and
                        css

                        openid_enabled: just what it says, painless
                        OpenId.

Monday, June 22, 2009                                                    49
To Wrap Up

                        Rails is fun to work with. I’m way more
                        productive now than I was before, happier too.

                        Rails is more flexible than it gets credit for.

                        It’s great for teams because it encourages good
                        behavior




Monday, June 22, 2009                                                     50
Questions?


Monday, June 22, 2009                51
Contact Info

                        kevin@uplaya.com

                        @kplawver on twitter

                        http://uplaya.com

                        http://lawver.net




Monday, June 22, 2009                          52
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails
Welcome To Ruby On Rails

More Related Content

Viewers also liked

Your Database is Trying to Kill You
Your Database is Trying to Kill YouYour Database is Trying to Kill You
Your Database is Trying to Kill YouKevin Lawver
 
HTML5: About Damn Time
HTML5: About Damn TimeHTML5: About Damn Time
HTML5: About Damn TimeKevin Lawver
 
Vocabulario o viño
Vocabulario o viñoVocabulario o viño
Vocabulario o viñoalxen
 
Súper Casares Paqui
Súper Casares PaquiSúper Casares Paqui
Súper Casares Paquialxen
 
Social Media Food Chain
Social Media Food ChainSocial Media Food Chain
Social Media Food ChainKevin Lawver
 
'UX', 'UX Design' and 'Good UX'
'UX', 'UX Design' and 'Good UX''UX', 'UX Design' and 'Good UX'
'UX', 'UX Design' and 'Good UX'Jinyong Kim
 

Viewers also liked (10)

Inspire u featuring allissa haines~marketing with personality
Inspire u featuring allissa haines~marketing with personalityInspire u featuring allissa haines~marketing with personality
Inspire u featuring allissa haines~marketing with personality
 
Inspire U Presents Aromatherapy for Special Populations
Inspire U Presents Aromatherapy for Special PopulationsInspire U Presents Aromatherapy for Special Populations
Inspire U Presents Aromatherapy for Special Populations
 
Inspire U Billing for Massage Therapists with Vivian mahoney1
Inspire U Billing for Massage Therapists with Vivian mahoney1Inspire U Billing for Massage Therapists with Vivian mahoney1
Inspire U Billing for Massage Therapists with Vivian mahoney1
 
Your Database is Trying to Kill You
Your Database is Trying to Kill YouYour Database is Trying to Kill You
Your Database is Trying to Kill You
 
CODE!
CODE!CODE!
CODE!
 
HTML5: About Damn Time
HTML5: About Damn TimeHTML5: About Damn Time
HTML5: About Damn Time
 
Vocabulario o viño
Vocabulario o viñoVocabulario o viño
Vocabulario o viño
 
Súper Casares Paqui
Súper Casares PaquiSúper Casares Paqui
Súper Casares Paqui
 
Social Media Food Chain
Social Media Food ChainSocial Media Food Chain
Social Media Food Chain
 
'UX', 'UX Design' and 'Good UX'
'UX', 'UX Design' and 'Good UX''UX', 'UX Design' and 'Good UX'
'UX', 'UX Design' and 'Good UX'
 

Similar to Welcome To Ruby On Rails

RubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with RubyRubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with RubyAstrails
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby DevelopersRenzo Borgatti
 
Beyond your daily coding - The Conf Brazil 2017 Keynote
Beyond your daily coding - The Conf Brazil 2017 KeynoteBeyond your daily coding - The Conf Brazil 2017 Keynote
Beyond your daily coding - The Conf Brazil 2017 KeynoteEmerson Macedo
 
Angular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User GroupAngular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User GroupManuel Kießling
 
Cloud4all Architecture Overview
Cloud4all Architecture OverviewCloud4all Architecture Overview
Cloud4all Architecture Overviewicchp2012
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Introducing Immutant
Introducing Immutant Introducing Immutant
Introducing Immutant Jim Crossley
 
Essential Node.js for Web Developers from Developer Week 2013
Essential Node.js for Web Developers from Developer Week 2013Essential Node.js for Web Developers from Developer Week 2013
Essential Node.js for Web Developers from Developer Week 2013CA API Management
 
Microsoft Hellas Dev Days 09: IronRuby
Microsoft Hellas Dev Days 09: IronRubyMicrosoft Hellas Dev Days 09: IronRuby
Microsoft Hellas Dev Days 09: IronRubyNikos Dimitrakopoulos
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First MileGourab Mitra
 
Real World Rails 5 Programming for Web Developers
Real World Rails 5 Programming for Web DevelopersReal World Rails 5 Programming for Web Developers
Real World Rails 5 Programming for Web Developersprshant navgrha
 
Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Ajax Experience 2009
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?Karmen Blake
 
Session dotNed Saturday 28 januari 2017
Session dotNed Saturday 28 januari 2017Session dotNed Saturday 28 januari 2017
Session dotNed Saturday 28 januari 2017Gerald Versluis
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Railsmithunsasidharan
 
Ruby JIT Compilation - Mykhail Bortnyk
Ruby JIT Compilation - Mykhail Bortnyk Ruby JIT Compilation - Mykhail Bortnyk
Ruby JIT Compilation - Mykhail Bortnyk Ruby Meditation
 

Similar to Welcome To Ruby On Rails (20)

RubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with RubyRubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with Ruby
 
Don Schwarz App Engine Talk
Don Schwarz App Engine TalkDon Schwarz App Engine Talk
Don Schwarz App Engine Talk
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
 
MacRuby on Rails
MacRuby on RailsMacRuby on Rails
MacRuby on Rails
 
Beyond your daily coding - The Conf Brazil 2017 Keynote
Beyond your daily coding - The Conf Brazil 2017 KeynoteBeyond your daily coding - The Conf Brazil 2017 Keynote
Beyond your daily coding - The Conf Brazil 2017 Keynote
 
Angular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User GroupAngular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User Group
 
Cloud4all Architecture Overview
Cloud4all Architecture OverviewCloud4all Architecture Overview
Cloud4all Architecture Overview
 
Clojure
ClojureClojure
Clojure
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Introducing Immutant
Introducing Immutant Introducing Immutant
Introducing Immutant
 
Essential Node.js for Web Developers from Developer Week 2013
Essential Node.js for Web Developers from Developer Week 2013Essential Node.js for Web Developers from Developer Week 2013
Essential Node.js for Web Developers from Developer Week 2013
 
Microsoft Hellas Dev Days 09: IronRuby
Microsoft Hellas Dev Days 09: IronRubyMicrosoft Hellas Dev Days 09: IronRuby
Microsoft Hellas Dev Days 09: IronRuby
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Real World Rails 5 Programming for Web Developers
Real World Rails 5 Programming for Web DevelopersReal World Rails 5 Programming for Web Developers
Real World Rails 5 Programming for Web Developers
 
Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]
 
Ruby on Rails Development Ecosystem
Ruby on Rails Development EcosystemRuby on Rails Development Ecosystem
Ruby on Rails Development Ecosystem
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?
 
Session dotNed Saturday 28 januari 2017
Session dotNed Saturday 28 januari 2017Session dotNed Saturday 28 januari 2017
Session dotNed Saturday 28 januari 2017
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Ruby JIT Compilation - Mykhail Bortnyk
Ruby JIT Compilation - Mykhail Bortnyk Ruby JIT Compilation - Mykhail Bortnyk
Ruby JIT Compilation - Mykhail Bortnyk
 

Recently uploaded

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 

Recently uploaded (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 

Welcome To Ruby On Rails

  • 1. Welcome to Ruby on Rails Kevin Lawver | June 25, 2009 http://uplaya.com Monday, June 22, 2009 1
  • 2. Hi, I’m Kevin Lawver Chief Architect at Music Intelligence Solutions - http://uplaya.com (it’s a Rails app) Worked at AOL for 13 years, launched two public Rails apps. Spent a lot of time on AOLserver using Tcl and Tomcat writing JSP’s. Just launched http://ficly.com with a friend as an “art project” (also on Rails) Monday, June 22, 2009 2
  • 3. What is Ruby? Object-oriented Interpreted Expressive “principle of least surprise” Monday, June 22, 2009 3
  • 4. “They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.” -- Matz Monday, June 22, 2009 4
  • 5. Everything’s an Object This confuses everyone at the beginning. Everything in Ruby is an object. There are no primitives, they’re all objects! Monday, June 22, 2009 5
  • 6. What’s Rails? Web framework written by DHH in 2003 at 37signals for Basecamp Takes most of the “grunt work” out of building web apps MVC “Optimized for programmer happiness and sustainable productivity” Monday, June 22, 2009 6
  • 7. Why Use It? Convention over configuration Quick prototyping - can turn into the “real” project without starting over Convention makes it easy to share code and quick to get started Because it’s Ruby, you can turn it into anything you want Monday, June 22, 2009 7
  • 8. Rails’ Components ActiveRecord ActionController ActionView ActiveResource ActiveSupport Monday, June 22, 2009 8
  • 9. ActiveRecord The “M” in MVC Rails’ crown jewel - a great database abstraction layer. Makes it really easy to work with databases. In Rails, your models should contain 95% of your business logic. Monday, June 22, 2009 9
  • 10. ActionController The “C” in MVC Handles routing requests and processing them. In Rails, your controllers should be light Monday, June 22, 2009 10
  • 11. ActionView The “V” in MVC Where you do all your HTML and most of your XML. I’ve used a dozen different template systems over the years and Rails’ is by far my favorite. Monday, June 22, 2009 11
  • 12. ActiveResource Rails’ built-in support for RESTful API’s Makes it easy to do REST the right way Provides a lot of the wrappers, error cases and connection code you need to do RESTy stuff. Monday, June 22, 2009 12
  • 13. ActiveSupport All the extensions to Ruby’s base classes A lot of “glue” for JSON and other things that don’t belong in the other pieces Monday, June 22, 2009 13
  • 14. My Favorite Things About Rails I can go from idea to “real” in hours instead of days. It’s easy to refactor single pieces without affecting the whole app. Plugins solve major problems without requiring rewrites (see cache money) Community is helpful and responsive Monday, June 22, 2009 14
  • 15. Getting Started I don’t use Windows, so you’re on your own there. If you use a Mac and have Leopard, you already have Ruby and Rails. Linux? There are dozens of tutorials for your distro, don’t worry. Monday, June 22, 2009 15
  • 16. The 20 Minute Blog Sorry if you’re following along online, I’m heading to terminal now. Monday, June 22, 2009 16
  • 17. What we’ll be doing Create a new Rails app for our awesome new blog Build a model, controller and view for it Look at some helpful gems and plugins Make a feed for it Talk a little about ActiveRecord callbacks Monday, June 22, 2009 17
  • 18. What we won’t be doing Talking about tests (they’re important, but I hate writing them) Spending a lot of time on configuration Monday, June 22, 2009 18
  • 19. What we’ll be doing (redux) Create a new Rails app for our awesome new blog Build a model, controller and view for it Look at some helpful gems and plugins Make a feed for it Talk a little about ActiveRecord callbacks Monday, June 22, 2009 19
  • 20. Wasn’t that fun? now let’s talk about myths! Monday, June 22, 2009 20
  • 21. Some Rails Myths “Rails doesn’t scale” “Ruby (or Rails) is too slow” “Rails locks you into doing it its way” “X is better!” (where X = “Python”, “PHP”, “Java” or whatever) Monday, June 22, 2009 21
  • 22. Myth: “Rails Doesn’t Scale” Monday, June 22, 2009 22
  • 23. Maybe 3 Years Ago Back then, we had to use FastCGI or Mongrel. Now, though, we can use Phusion Passenger! It’s an Apache plugin that does a great job of managing Rails instances. And Ruby Enterprise Edition makes Rails use less memory and run faster. Brilliant! Monday, June 22, 2009 23
  • 24. Live-World Examples uplaya.com handles tens of thousands of requests a day on a couple tiny Amazon EC2 instances (we could do everything on one with room to spare, but I like having backup). ficly.com handles tens of thousands of requests a day on a single quad core server - that’s not even breaking a sweat yet. hundreds of other sites handle a lot more traffic with minimal hardware or fuss. Monday, June 22, 2009 24
  • 25. You will probably never need to scale. Monday, June 22, 2009 25
  • 26. But if you do... Monday, June 22, 2009 26
  • 27. The Data Layer Your database will fall over before your web server does. Optimize your connection, queries and indexes Protect your database by using memcached between your front-end and database Monday, June 22, 2009 27
  • 28. Cache, Cache, Cache memcached is your friend Disk-based caches don’t work once you grow beyond one server - same thing for in-memory caches Caching hides a world of programming sins, and saves you from having to do ugly things like sharding. Monday, June 22, 2009 28
  • 29. You Don’t Want... to be both read-heavy and write-heavy to have complex queries that can’t be cached to have to do multiple selects on a single request Monday, June 22, 2009 29
  • 30. The Most Important Thing is to launch! If you never launch, you’ll never have users. If you never have users, you’ll never have to scale. Rails helps me get from nothing to launch faster than anything else I’ve tried. It helps me get from launch to scale pretty quickly as well. Monday, June 22, 2009 30
  • 31. Typical Rails Stack Apache w/ Passenger *x MySQL Master memcached * y Slave Readers * z Writer Monday, June 22, 2009 31
  • 32. Myth: “Ruby is too slow!” Monday, June 22, 2009 32
  • 33. But, it’s fast enough for the web. Monday, June 22, 2009 33
  • 34. For all of my sites... No request takes longer than 1 second On uPlaya, the average time per request is 217 milliseconds. On Ficly, the average time per request is 165 milliseconds. That’s more than fast enough for the web. Monday, June 22, 2009 34
  • 35. The “Slow” in Rails Is the same slow anywhere else: Database The Internet CPU, Disk or RAM Monday, June 22, 2009 35
  • 36. Those factors affect everyone, not just Rails Monday, June 22, 2009 36
  • 37. Performance Gotchas Database indexes. If you’re selecting or sorting by a column, it should have an index! You won’t know you need them until it’s too late. Static assets. Set up a separate virtual host for static stuff, or move them to a CDN. Don’t make Rails serve static stuff! Selects. Tune your cache so you can average zero reads per page view, if possible. Monday, June 22, 2009 37
  • 38. Myth: Rails makes you do things its way Monday, June 22, 2009 38
  • 39. It doesn’t make you. Monday, June 22, 2009 39
  • 40. It encourages you. Monday, June 22, 2009 40
  • 41. Plus, Rails’ way probably is the right way. Monday, June 22, 2009 41
  • 42. And if not, you can write a plugin to make it do it your way. Monday, June 22, 2009 42
  • 43. Myth: “X is better!” Monday, June 22, 2009 43
  • 44. Your point is? Monday, June 22, 2009 44
  • 45. Religious battles over programming languages are stupid. Monday, June 22, 2009 45
  • 46. Use what makes you happy and productive. Monday, June 22, 2009 46
  • 47. Why You Shouldn’t Use Rails You have a legacy database that you can’t change. You could make it work with Rails, but it probably wouldn’t be much fun. You’re happy with what you’ve got and hate learning. You don’t ever talk to a database. Rails pretty much is ActiveRecord, so if you’re not using it, you might be better off with something else. Monday, June 22, 2009 47
  • 48. Gems! gem sources -a http://gems.github.com Pagination: mislav-will_paginate Faster URLs: pauldix-typhoeus Twitterness: hayesdavis-grackle Faster XML or HTML parsing: nokogiri or hpricot Monday, June 22, 2009 48
  • 49. Rails Plugins FTW! cache-money: a write-through cache for ActiveRecord. attachment_fu: great for handling uploads and storing them on s3 smurf: automatic minification of javascript and css openid_enabled: just what it says, painless OpenId. Monday, June 22, 2009 49
  • 50. To Wrap Up Rails is fun to work with. I’m way more productive now than I was before, happier too. Rails is more flexible than it gets credit for. It’s great for teams because it encourages good behavior Monday, June 22, 2009 50
  • 52. Contact Info kevin@uplaya.com @kplawver on twitter http://uplaya.com http://lawver.net Monday, June 22, 2009 52