SlideShare ist ein Scribd-Unternehmen logo
1 von 24
An Introduction to
Ruby and Rails
Matthew Bohnsack
Wannabe Rubyist
November 9th 2005
Outline
   What is Ruby and why should I care?
   What is Rails and why should I care?
   Two must-have tools for Ruby development
   Major Ruby features (the language in a nutshell)
   Rails overview
   Where to go for more information
   Questions / Hacking


November 9th 2005   An Introduction to Ruby and Rails   2
What is Ruby? Why should I care?
   What:
      The Wikipedia answer is here.
      Created/lead by Matz (Japanese)
      Open Source interpreted scripting language, like Perl, Python,
       Tcl, etc., but focused on being very object oriented, expressive,
       and bringing joy to programming.
      Principle of least surprise
   Why:
      Productivity ideas presented in Ousterhout’s 1998 paper coming
       to very serious critical mass (and beyond)
      Learn a new language to learn new ways of thinking about code
       in any language (e.g., blocks and iterators)
      Joy!



November 9th 2005         An Introduction to Ruby and Rails                3
What is Rails? Why should I care?
   What:
      Web Framework that makes building database-driven MVC-oriented web apps
       easy through a template engine, ORM (ActiveRecord) and other best practices,
       such as test driven development, deployment tools, patterns, etc.
      Much less complicated than J2EE solutions, but perhaps more so than PHP or
       Perl in cgi-bin.
      Copy cats are being created in other languages:
              Python (TurboGears)
              Perl (Maypole)
        http://rubyonrails.org/ + book + online screencasts + online docs & tutorials
   Why:
        I’ve been watching the world of web development since ~ 1995, and I’ve never
         seen anything like Rails in terms of buzz, momentum, adoption rate, etc.




November 9th 2005                    An Introduction to Ruby and Rails                   4
Must have tool #1: irb
                                                     # ~/.irbrc

   Interactive ruby console:                        require 'irb/completion'
                                                     use_readline=true
      Experimenton the fly     auto_indent_mode=true

      Tab complete object methods
     …




November 9th 2005    An Introduction to Ruby and Rails                          5
Must have tool #2: ri
   Console-based Ruby doc tool




November 9th 2005   An Introduction to Ruby and Rails   6
Ruby in a nutshell – irb sessions
follow
   Like all interpreted scripting languages, you can
    put code into a file, chmod +x, then just execute
    it.




   But, we’ll mostly use irb sessions in this
    presentation…

November 9th 2005    An Introduction to Ruby and Rails   7
Ruby in a nutshell – objects are
everywhere
   Some languages have built-in types that aren’t
    objects. Not so with Ruby. Everything’s an
    object:




November 9th 2005   An Introduction to Ruby and Rails   8
Ruby in a nutshell – objects have
methods




      Bang on the tab key in irb to see the methods that are available for
      each object.


November 9th 2005            An Introduction to Ruby and Rails               9
Ruby in a nutshell – Variables
   Local variables - start with lower case:
      foo
      bar
   Global variables - start with dollar sign:
      $foo
      $bar
   Constants and Classes – start with capital letter:
      CONSTANT
      Class
   Instance variables – start with at sign:
      @foo
      @bar
   Class variables – start with double at sign:
      @@foo
      @@bar




November 9th 2005              An Introduction to Ruby and Rails   10
Ruby in a nutshell – Arrays




November 9th 2005   An Introduction to Ruby and Rails   11
Ruby in a nutshell – Hashes




November 9th 2005   An Introduction to Ruby and Rails   12
Ruby in a nutshell – Symbols
   Starts with a ‘:’
   Only one copy of a symbol kept in memory




November 9th 2005        An Introduction to Ruby and Rails   13
Ruby in a nutshell – Blocks & Iterators




November 9th 2005   An Introduction to Ruby and Rails   14
Ruby in a nutshell – It’s easy to build
classes




November 9th 2005   An Introduction to Ruby and Rails   15
Ruby in a nutshell – It’s fun to play with
classes (like the one we just made)




November 9th 2005   An Introduction to Ruby and Rails   16
Ruby in a nutshell – Classes are open
   Example shown here uses our Hacker
    class, but what happens when the whole
    language is open?




November 9th 2005   An Introduction to Ruby and Rails   17
Ruby in a nutshell – Other notes on
Classes
   Ruby only has single inheritance. This
    makes things simpler, but mix-ins provide
    much of multiple inheritance’s benefit,
    without the hassle.




November 9th 2005   An Introduction to Ruby and Rails   18
Ruby in a nutshell – a few gotchas
   Despite the principle of least surprise:
      Zero         isn’t false:




      No      increment operator (foo++). Instead use:
              foo += 1
              foo = foo + 1


November 9th 2005                  An Introduction to Ruby and Rails   19
Ruby in a nutshell – RubyGems

 CPAN for Ruby?
  http://docs.rubygems.org/
 Examples:
        gem list
        gem install redcloth --version ">= 3.0.0"
     …
   Using gems in your program:
      require ‘rubygems’
      require ‘some_gem’

November 9th 2005      An Introduction to Ruby and Rails   20
Want to learn more Ruby?
   Excellent, simple, beginner’s tutorial:
      http://www.math.umd.edu/~dcarrera/ruby/0.3/index.html
   Other stuff at end of talk
   Start hacking




November 9th 2005        An Introduction to Ruby and Rails     21
Quick Rails Demo – Build a TODO
list application in 5 minutes
   Define database
   rails todo
   cd todo
   Edit config/database.yml
   ./script/generate model Todo
   ./script/generate scaffold todo
   Look at scaffolding
   ./script/server –b www.bohnsack.com
   Add due_date field, regenerate scaffolding, and check the results
   ./script/console




November 9th 2005         An Introduction to Ruby and Rails             22
Where to go for more information
   Books:




   Online material:
        First edition of Pickaxe online for free
        http://www.ruby-doc.org/
        why’s (poignant) guide to Ruby
        http://rubyonrails.org/
        Rails screencast(s)
        Planet Ruby on Rails




November 9th 2005                 An Introduction to Ruby and Rails   23
The End / Questions




November 9th 2005   An Introduction to Ruby and Rails   24

Weitere ähnliche Inhalte

Was ist angesagt?

TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotationsmametter
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutinesRoman Elizarov
 
Iron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NETIron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NETKristian Kristensen
 
Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - IntroductionKwangshin Oh
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3mametter
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOpsRicardo Sanchez
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formattersVisuality
 
Enjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfEnjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfmametter
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLAlex Sharp
 
Special Subject 1+2: RoR 2
Special Subject 1+2: RoR 2Special Subject 1+2: RoR 2
Special Subject 1+2: RoR 2Stefan Fodor
 
Sharing (or stealing) the jewels of python with big data & the jvm (1)
Sharing (or stealing) the jewels of python with big data & the jvm (1)Sharing (or stealing) the jewels of python with big data & the jvm (1)
Sharing (or stealing) the jewels of python with big data & the jvm (1)Holden Karau
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
Opal - Ruby Style!! Ruby in the browser
Opal - Ruby Style!!  Ruby in the browserOpal - Ruby Style!!  Ruby in the browser
Opal - Ruby Style!! Ruby in the browserForrest Chang
 

Was ist angesagt? (19)

TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 
Iron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NETIron* - An Introduction to Getting Dynamic on .NET
Iron* - An Introduction to Getting Dynamic on .NET
 
Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - Introduction
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
Kotlin from-scratch
Kotlin from-scratchKotlin from-scratch
Kotlin from-scratch
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
 
Ruby Loves Dot Net
Ruby Loves Dot NetRuby Loves Dot Net
Ruby Loves Dot Net
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formatters
 
Enjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfEnjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProf
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSL
 
Special Subject 1+2: RoR 2
Special Subject 1+2: RoR 2Special Subject 1+2: RoR 2
Special Subject 1+2: RoR 2
 
Crystal
CrystalCrystal
Crystal
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
Sharing (or stealing) the jewels of python with big data & the jvm (1)
Sharing (or stealing) the jewels of python with big data & the jvm (1)Sharing (or stealing) the jewels of python with big data & the jvm (1)
Sharing (or stealing) the jewels of python with big data & the jvm (1)
 
MacRuby
MacRubyMacRuby
MacRuby
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
Opal - Ruby Style!! Ruby in the browser
Opal - Ruby Style!!  Ruby in the browserOpal - Ruby Style!!  Ruby in the browser
Opal - Ruby Style!! Ruby in the browser
 

Andere mochten auch

Yohn erney cardona 9ºd
Yohn erney cardona 9ºdYohn erney cardona 9ºd
Yohn erney cardona 9ºdyohnerney
 
Codes and conventions of thriller films
Codes and conventions of thriller filmsCodes and conventions of thriller films
Codes and conventions of thriller filmsNathalieO
 
Locations powerpoint
Locations powerpointLocations powerpoint
Locations powerpointNathalieO
 
Lampiran surat pengumuman pkm didanai 2012 3
Lampiran surat pengumuman pkm didanai 2012 3Lampiran surat pengumuman pkm didanai 2012 3
Lampiran surat pengumuman pkm didanai 2012 3Hanif Arian
 
Test presentation
Test presentationTest presentation
Test presentationedatactive
 

Andere mochten auch (7)

Chap01
Chap01Chap01
Chap01
 
Yohn erney cardona 9ºd
Yohn erney cardona 9ºdYohn erney cardona 9ºd
Yohn erney cardona 9ºd
 
My very first power point
My very first power pointMy very first power point
My very first power point
 
Codes and conventions of thriller films
Codes and conventions of thriller filmsCodes and conventions of thriller films
Codes and conventions of thriller films
 
Locations powerpoint
Locations powerpointLocations powerpoint
Locations powerpoint
 
Lampiran surat pengumuman pkm didanai 2012 3
Lampiran surat pengumuman pkm didanai 2012 3Lampiran surat pengumuman pkm didanai 2012 3
Lampiran surat pengumuman pkm didanai 2012 3
 
Test presentation
Test presentationTest presentation
Test presentation
 

Ähnlich wie Intro for RoR

Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsManoj Kumar
 
P4 P Update January 2009
P4 P Update January 2009P4 P Update January 2009
P4 P Update January 2009vsainteluce
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorialknoppix
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Espen Brækken
 
Ruby'on'rails
Ruby'on'railsRuby'on'rails
Ruby'on'railsgmergel
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasilecsette
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_pythontutorialsruby
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_pythontutorialsruby
 
Ruby On Rails pizza training
Ruby On Rails pizza trainingRuby On Rails pizza training
Ruby On Rails pizza trainingdavid_alphen
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approachFelipe Schmitt
 
Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalAndy Maleh
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsEleni Huebsch
 

Ähnlich wie Intro for RoR (20)

Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
P4 P Update January 2009
P4 P Update January 2009P4 P Update January 2009
P4 P Update January 2009
 
Ebay News 2000 10 19 Earnings
Ebay News 2000 10 19 EarningsEbay News 2000 10 19 Earnings
Ebay News 2000 10 19 Earnings
 
Ebay News 2001 4 19 Earnings
Ebay News 2001 4 19 EarningsEbay News 2001 4 19 Earnings
Ebay News 2001 4 19 Earnings
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
 
Ruby'on'rails
Ruby'on'railsRuby'on'rails
Ruby'on'rails
 
Ruby hellug
Ruby hellugRuby hellug
Ruby hellug
 
Book of ruby
Book of rubyBook of ruby
Book of ruby
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasil
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
 
ruby_vs_perl_and_python
ruby_vs_perl_and_pythonruby_vs_perl_and_python
ruby_vs_perl_and_python
 
Ruby On Rails pizza training
Ruby On Rails pizza trainingRuby On Rails pizza training
Ruby On Rails pizza training
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Ruby Beyond Rails
Ruby Beyond RailsRuby Beyond Rails
Ruby Beyond Rails
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
 
Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Why ruby
Why rubyWhy ruby
Why ruby
 
Ruby programming
Ruby programmingRuby programming
Ruby programming
 

Kürzlich hochgeladen

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Intro for RoR

  • 1. An Introduction to Ruby and Rails Matthew Bohnsack Wannabe Rubyist November 9th 2005
  • 2. Outline  What is Ruby and why should I care?  What is Rails and why should I care?  Two must-have tools for Ruby development  Major Ruby features (the language in a nutshell)  Rails overview  Where to go for more information  Questions / Hacking November 9th 2005 An Introduction to Ruby and Rails 2
  • 3. What is Ruby? Why should I care?  What:  The Wikipedia answer is here.  Created/lead by Matz (Japanese)  Open Source interpreted scripting language, like Perl, Python, Tcl, etc., but focused on being very object oriented, expressive, and bringing joy to programming.  Principle of least surprise  Why:  Productivity ideas presented in Ousterhout’s 1998 paper coming to very serious critical mass (and beyond)  Learn a new language to learn new ways of thinking about code in any language (e.g., blocks and iterators)  Joy! November 9th 2005 An Introduction to Ruby and Rails 3
  • 4. What is Rails? Why should I care?  What:  Web Framework that makes building database-driven MVC-oriented web apps easy through a template engine, ORM (ActiveRecord) and other best practices, such as test driven development, deployment tools, patterns, etc.  Much less complicated than J2EE solutions, but perhaps more so than PHP or Perl in cgi-bin.  Copy cats are being created in other languages:  Python (TurboGears)  Perl (Maypole)  http://rubyonrails.org/ + book + online screencasts + online docs & tutorials  Why:  I’ve been watching the world of web development since ~ 1995, and I’ve never seen anything like Rails in terms of buzz, momentum, adoption rate, etc. November 9th 2005 An Introduction to Ruby and Rails 4
  • 5. Must have tool #1: irb # ~/.irbrc  Interactive ruby console: require 'irb/completion' use_readline=true  Experimenton the fly auto_indent_mode=true  Tab complete object methods … November 9th 2005 An Introduction to Ruby and Rails 5
  • 6. Must have tool #2: ri  Console-based Ruby doc tool November 9th 2005 An Introduction to Ruby and Rails 6
  • 7. Ruby in a nutshell – irb sessions follow  Like all interpreted scripting languages, you can put code into a file, chmod +x, then just execute it.  But, we’ll mostly use irb sessions in this presentation… November 9th 2005 An Introduction to Ruby and Rails 7
  • 8. Ruby in a nutshell – objects are everywhere  Some languages have built-in types that aren’t objects. Not so with Ruby. Everything’s an object: November 9th 2005 An Introduction to Ruby and Rails 8
  • 9. Ruby in a nutshell – objects have methods Bang on the tab key in irb to see the methods that are available for each object. November 9th 2005 An Introduction to Ruby and Rails 9
  • 10. Ruby in a nutshell – Variables  Local variables - start with lower case:  foo  bar  Global variables - start with dollar sign:  $foo  $bar  Constants and Classes – start with capital letter:  CONSTANT  Class  Instance variables – start with at sign:  @foo  @bar  Class variables – start with double at sign:  @@foo  @@bar November 9th 2005 An Introduction to Ruby and Rails 10
  • 11. Ruby in a nutshell – Arrays November 9th 2005 An Introduction to Ruby and Rails 11
  • 12. Ruby in a nutshell – Hashes November 9th 2005 An Introduction to Ruby and Rails 12
  • 13. Ruby in a nutshell – Symbols  Starts with a ‘:’  Only one copy of a symbol kept in memory November 9th 2005 An Introduction to Ruby and Rails 13
  • 14. Ruby in a nutshell – Blocks & Iterators November 9th 2005 An Introduction to Ruby and Rails 14
  • 15. Ruby in a nutshell – It’s easy to build classes November 9th 2005 An Introduction to Ruby and Rails 15
  • 16. Ruby in a nutshell – It’s fun to play with classes (like the one we just made) November 9th 2005 An Introduction to Ruby and Rails 16
  • 17. Ruby in a nutshell – Classes are open  Example shown here uses our Hacker class, but what happens when the whole language is open? November 9th 2005 An Introduction to Ruby and Rails 17
  • 18. Ruby in a nutshell – Other notes on Classes  Ruby only has single inheritance. This makes things simpler, but mix-ins provide much of multiple inheritance’s benefit, without the hassle. November 9th 2005 An Introduction to Ruby and Rails 18
  • 19. Ruby in a nutshell – a few gotchas  Despite the principle of least surprise:  Zero isn’t false:  No increment operator (foo++). Instead use:  foo += 1  foo = foo + 1 November 9th 2005 An Introduction to Ruby and Rails 19
  • 20. Ruby in a nutshell – RubyGems  CPAN for Ruby? http://docs.rubygems.org/  Examples:  gem list  gem install redcloth --version ">= 3.0.0" …  Using gems in your program:  require ‘rubygems’  require ‘some_gem’ November 9th 2005 An Introduction to Ruby and Rails 20
  • 21. Want to learn more Ruby?  Excellent, simple, beginner’s tutorial:  http://www.math.umd.edu/~dcarrera/ruby/0.3/index.html  Other stuff at end of talk  Start hacking November 9th 2005 An Introduction to Ruby and Rails 21
  • 22. Quick Rails Demo – Build a TODO list application in 5 minutes  Define database  rails todo  cd todo  Edit config/database.yml  ./script/generate model Todo  ./script/generate scaffold todo  Look at scaffolding  ./script/server –b www.bohnsack.com  Add due_date field, regenerate scaffolding, and check the results  ./script/console November 9th 2005 An Introduction to Ruby and Rails 22
  • 23. Where to go for more information  Books:  Online material:  First edition of Pickaxe online for free  http://www.ruby-doc.org/  why’s (poignant) guide to Ruby  http://rubyonrails.org/  Rails screencast(s)  Planet Ruby on Rails November 9th 2005 An Introduction to Ruby and Rails 23
  • 24. The End / Questions November 9th 2005 An Introduction to Ruby and Rails 24