Your SlideShare is downloading. ×
0
An Introduction toRuby and RailsMatthew BohnsackWannabe RubyistNovember 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 dev...
What is Ruby? Why should I care?   What:      The Wikipedia answer is here.      Created/lead by Matz (Japanese)      ...
What is Rails? Why should I care?   What:      Web Framework that makes building database-driven MVC-oriented web apps  ...
Must have tool #1: irb                                                     # ~/.irbrc   Interactive ruby console:        ...
Must have tool #2: ri   Console-based Ruby doc toolNovember 9th 2005   An Introduction to Ruby and Rails   6
Ruby in a nutshell – irb sessionsfollow   Like all interpreted scripting languages, you can    put code into a file, chmo...
Ruby in a nutshell – objects areeverywhere   Some languages have built-in types that aren’t    objects. Not so with Ruby....
Ruby in a nutshell – objects havemethods      Bang on the tab key in irb to see the methods that are available for      ea...
Ruby in a nutshell – Variables   Local variables - start with lower case:      foo      bar   Global variables - start...
Ruby in a nutshell – ArraysNovember 9th 2005   An Introduction to Ruby and Rails   11
Ruby in a nutshell – HashesNovember 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 memoryNovember 9th 2005        An I...
Ruby in a nutshell – Blocks & IteratorsNovember 9th 2005   An Introduction to Ruby and Rails   14
Ruby in a nutshell – It’s easy to buildclassesNovember 9th 2005   An Introduction to Ruby and Rails   15
Ruby in a nutshell – It’s fun to play withclasses (like the one we just made)November 9th 2005   An Introduction to Ruby a...
Ruby in a nutshell – Classes are open   Example shown here uses our Hacker    class, but what happens when the whole    l...
Ruby in a nutshell – Other notes onClasses   Ruby only has single inheritance. This    makes things simpler, but mix-ins ...
Ruby in a nutshell – a few gotchas   Despite the principle of least surprise:      Zero         isn’t false:      No   ...
Ruby in a nutshell – RubyGems CPAN for Ruby?  http://docs.rubygems.org/ Examples:        gem list        gem install r...
Want to learn more Ruby?   Excellent, simple, beginner’s tutorial:      http://www.math.umd.edu/~dcarrera/ruby/0.3/index...
Quick Rails Demo – Build a TODOlist application in 5 minutes   Define database   rails todo   cd todo   Edit config/da...
Where to go for more information   Books:   Online material:        First edition of Pickaxe online for free        ht...
The End / QuestionsNovember 9th 2005   An Introduction to Ruby and Rails   24
Upcoming SlideShare
Loading in...5
×

Intro for RoR

612

Published on

Introduction For Ruby On Rails

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
612
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Intro for RoR"

  1. 1. An Introduction toRuby and RailsMatthew BohnsackWannabe RubyistNovember 9th 2005
  2. 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 / HackingNovember 9th 2005 An Introduction to Ruby and Rails 2
  3. 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. 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. 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. 6. Must have tool #2: ri Console-based Ruby doc toolNovember 9th 2005 An Introduction to Ruby and Rails 6
  7. 7. Ruby in a nutshell – irb sessionsfollow 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. 8. Ruby in a nutshell – objects areeverywhere 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. 9. Ruby in a nutshell – objects havemethods 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. 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  @@barNovember 9th 2005 An Introduction to Ruby and Rails 10
  11. 11. Ruby in a nutshell – ArraysNovember 9th 2005 An Introduction to Ruby and Rails 11
  12. 12. Ruby in a nutshell – HashesNovember 9th 2005 An Introduction to Ruby and Rails 12
  13. 13. Ruby in a nutshell – Symbols Starts with a ‘:’ Only one copy of a symbol kept in memoryNovember 9th 2005 An Introduction to Ruby and Rails 13
  14. 14. Ruby in a nutshell – Blocks & IteratorsNovember 9th 2005 An Introduction to Ruby and Rails 14
  15. 15. Ruby in a nutshell – It’s easy to buildclassesNovember 9th 2005 An Introduction to Ruby and Rails 15
  16. 16. Ruby in a nutshell – It’s fun to play withclasses (like the one we just made)November 9th 2005 An Introduction to Ruby and Rails 16
  17. 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. 18. Ruby in a nutshell – Other notes onClasses 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. 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 + 1November 9th 2005 An Introduction to Ruby and Rails 19
  20. 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. 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 hackingNovember 9th 2005 An Introduction to Ruby and Rails 21
  22. 22. Quick Rails Demo – Build a TODOlist 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/consoleNovember 9th 2005 An Introduction to Ruby and Rails 22
  23. 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 RailsNovember 9th 2005 An Introduction to Ruby and Rails 23
  24. 24. The End / QuestionsNovember 9th 2005 An Introduction to Ruby and Rails 24
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×