0
An Introduction to Ruby and Rails Matthew Bohnsack Wannabe Rubyist November 9 th  2005
Outline <ul><li>What is Ruby and why should I care? </li></ul><ul><li>What is Rails and why should I care? </li></ul><ul><...
What is Ruby?  Why should I care? <ul><li>What: </li></ul><ul><ul><li>The Wikipedia answer is here . </li></ul></ul><ul><u...
What is Rails?  Why should I care? <ul><li>What: </li></ul><ul><ul><li>Web Framework that makes building database-driven M...
Must have tool #1:  irb <ul><li>Interactive ruby console : </li></ul><ul><ul><li>Experiment on the fly </li></ul></ul><ul>...
Must have tool #2:  ri <ul><li>Console-based Ruby doc tool </li></ul>November 9th 2005 An Introduction to Ruby and Rails
Ruby in a nutshell – irb sessions follow <ul><li>Like all interpreted scripting languages, you can put code into a file, c...
Ruby in a nutshell – objects are everywhere <ul><li>Some languages have built-in types that aren’t objects. Not so with Ru...
Ruby in a nutshell – objects have methods November 9th 2005 An Introduction to Ruby and Rails Bang on the tab key in irb t...
Ruby in a nutshell – Variables <ul><li>Local variables - start with lower case: </li></ul><ul><ul><li>foo </li></ul></ul><...
Ruby in a nutshell – Arrays November 9th 2005 An Introduction to Ruby and Rails
Ruby in a nutshell – Hashes November 9th 2005 An Introduction to Ruby and Rails
Ruby in a nutshell – Symbols <ul><li>Starts with a ‘:’ </li></ul><ul><li>Only one copy of a symbol kept in memory </li></u...
Ruby in a nutshell – Blocks & Iterators November 9th 2005 An Introduction to Ruby and Rails
Ruby in a nutshell – It’s easy to build classes November 9th 2005 An Introduction to Ruby and Rails
Ruby in a nutshell – It’s fun to play with classes (like the one we just made) November 9th 2005 An Introduction to Ruby a...
Ruby in a nutshell – Classes are open <ul><li>Example shown here uses our Hacker class, but what happens when the whole la...
Ruby in a nutshell – Other notes on Classes <ul><li>Ruby only has single inheritance.  This makes things simpler, but mix-...
Ruby in a nutshell – a few gotchas <ul><li>Despite the principle of least surprise: </li></ul><ul><ul><li>Zero isn’t false...
Ruby in a nutshell – RubyGems <ul><li>CPAN for Ruby?  http://docs.rubygems.org/ </li></ul><ul><li>Examples: </li></ul><ul>...
Want to learn more Ruby?  <ul><li>Excellent, simple, beginner’s tutorial: </li></ul><ul><ul><li>http://www.math.umd.edu/~d...
Quick Rails Demo – Build a TODO list application in 5 minutes <ul><li>Define database </li></ul><ul><li>rails todo </li></...
Where to go for more information <ul><li>Books: </li></ul><ul><li>Online material: </li></ul><ul><ul><li>First edition of ...
The End / Questions November 9th 2005 An Introduction to Ruby and Rails
Upcoming SlideShare
Loading in...5
×

Intro To Ror

2,211

Published on

Published in: Business, Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
2,211
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
58
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Intro To Ror"

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

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

×