SlideShare a Scribd company logo
An  INTRODUCTION   to  Ruby on Rails Nguyen Vu Hung [email_address] 2010/05/05
Agenda Ruby – The language. Ruby on Rails
Ruby – The language Made in Japan Creator:  まつもとゆきひろ Influenced by Perl, Smalltalk, Eiffel and Lisp. Multi-paradigm programming  language: Functional, Object oriented, Imperative and Reflective. Dynamic and automatic memory management.  Written in C Single-pass interpreted language (CLI, Interactive Ruby Shell)
まつもとゆきひろ Yukihiro Matsumoto 松本行弘 Born 1965 Computer scientist Programmer Compiler
Ruby influenced by Perl CLI Scripting language Simple Smalltalk Object-oriented Dynamically typed Reflective Can observe and modify its own structure and behavior Eiffel Lisp Originally specified in 1958 Fully parenthesized syntax
Functional language Emphasizes the application of functions. Everything is a function. class Array  def  iterate (code)  self.each_with_index do |n, i|    self[i] = code.call(n)  end  end  end  array = [1, 2, 3, 4]  array. iterate (l ambda  { |n| n ** 2 })  puts array.inspect  # => [1, 4, 9, 16]
Object oriented Similar to Java, PHP, Perl end end Point.new(@x*scalar, @y*scalar) def *(scalar)  # To perform scalar multiplication Point.new(-@x, -@y) end def -@  # Define unary minus to negate x and y Point.new(@x + other.x, @y + other.y) end def +(other)  # Define + to do vector addition @x,@y = x, y end Class Point attr_reader :x, :y  # Define accessor methods
Imperative Language TBD
Reflective Language TBD TBD: Java Reflection.
Ruby on Rails Open source   web application framework MIT license. Used with  Agile development methodology Rail architecture A MVC model Scaffolding : Automatically creates a skeleton of a basic website. WEBrick. Mongrel: Web servers. Rake: A build system. Test-Driven ActiveRecord   An  object-relational mapping  system for database access
Rails architecture: MVC
Rails architecture: 3-tier, N-tier? http://picasaweb.google.com/Dikiwinky/Ruby#5116531304417868130
Rails architecture: MVC Q: Where is M, V and C?
Ruby Agile Development Iterative development. Self organized.  Cross-functional team. Leadership philosophy: No real leader. Frequent inspection and adaptation. Allow high-quality. Rapid delivery.
Ruby  Scaffolding Generate source as needed-> Create a database (cookbook) Configure /config/database.yml  Generate source code: ruby script/generate scaffold Recipe title:string chef:string instructions:text
exists app/models/ exists app/controllers/  exists app/helpers/ create app/views/recipes  exists app/views/layouts/ exists test/functional/  exists test/unit/ exists public/stylesheets/  create app/views/recipes/index.html.erb  create app/views/recipes/show.html.erb  create app/views/recipes/new.html.erb  create app/views/recipes/edit.html.erb  create app/views/layouts/recipes.html.erb  create public/stylesheets/scaffold.css  create app/controllers/recipes_controller.rb  create test/functional/recipes_controller_test.rb  create app/helpers/recipes_helper.rb  route map.resources :recipes  dependency model exists  app/models/ exists test/unit/ exists  test/fixtures/ create app/models/recipe.rb  create test/unit/recipe_test.rb  create test/fixtures/recipes.yml  create db/migrate  create db/migrate/20080614192220_create_recipes.rb
exists app/models/  exists app/controllers/  exists app/helpers/  create app/views/recipes  exists app/views/layouts/ exists test/functional/  exists test/unit/ exists public/stylesheets/  create app/views/recipes/index.html.erb  create app/views/recipes/show.html.erb  create app/views/recipes/new.html.erb  create app/views/recipes/edit.html.erb  create app/views/layouts/recipes.html.erb  create public/stylesheets/scaffold.css  create app/controllers/recipes_controller.rb  create test/functional/recipes_controller_test.rb  create app/helpers/recipes_helper.rb  route map.resources :recipes  dependency model exists  app/models/ exists test/unit/ exists  test/fixtures/ create app/models/recipe.rb  create test/unit/recipe_test.rb  create test/fixtures/recipes.yml  create db/migrate  create db/migrate/20080614192220_create_recipes.rb
Ruby, Rails Installation CentOS 5: yum install -y ruby yum install -y ruby-devel ruby-docs ruby-ri ruby-irb ruby-rdoc tar xzvf rubygems-1.3.1.tgz cd rubygems sudo ruby setup.rb  sudo gem update  sudo gem install rails  Windows http://rubyonrails.org/download
Gems installed on Server 123 [vuhung@vinicorp ~]$ sudo gem list *** LOCAL GEMS *** actionmailer  (2.3.5, 2.2.2) actionpack  (2.3.5, 2.2.2) activerecord (2.3.5, 2.2.2) activeresource  (2.3.5, 2.2.2) activesupport  (2.3.5, 2.2.2) eventmachine  (0.12.10) fastthread  (1.0.7) htmlentities  (4.2.0) json  (1.2.0) juggernaut  (0.5.8) passenger  (2.2.9) rack  (1.0.1) rails  (2.3.5, 2.2.2) rake  (0.8.7
Rake A software building tool (automatically).  Written in Ruby. Configuration file: Rakefiles, ruby syntax. Common task can be done by ruby blocks (make cannot). Rake GNU make
Test-Driven Development Test first Write test-cases first. Automatic test cases generation. Short development circle. Regression test. Automated unit test. “Test” folder generated by Rake.
A short tutorial [vuhung@vinicorp ~]$ irb irb(main):001:0> puts "Hello Worlds" Hello Worlds => nil irb(main):002:0> 3+2 => 5 irb(main):003:0> 3*2 => 6 irb(main):004:0> 3**2 => 9 irb(main):005:0> Math.sqrt(9) => 3.0 irb(main):006:0> a = 3**2 => 9 irb(main):007:0> b = 4**2 => 16 irb(main):008:0> Math.sqrt(a+b) => 5.0 irb(main):009:0>
Redmine Web based Project Management Application. Written in Ruby on Rails GPL v2 licensed (free software). Rake as build system.  Gems WEBrick Plenty of plugins available. Stable since 2009/11 to date. Supports various DB back-end after Rails.
Redmine Folder Structure (2) ls -1 /var/www/html/redmine/redmine-0.8.7 app config db doc extra files lang lib log public Rakefile script start_redmine.sh test tmp vendor
 
TODO http://www.railstutorial.org/book#top http://www.railstutorial.org/chapters/a-demo-app#top http://www.railstutorial.org/chapters/static-pages#top http://www.railstutorial.org/chapters/rails-flavored-ruby#top http://www.railstutorial.org/chapters/filling-in-the-layout#top http://www.railstutorial.org/chapters/modeling-and-viewing-users-one#top http://www.railstutorial.org/chapters/modeling-and-viewing-users-two#top http://www.railstutorial.org/chapters/sign-up#top http://www.railstutorial.org/chapters/sign-in-sign-out#top http://www.railstutorial.org/chapters/updating-showing-and-deleting-users#top
TODO http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/strings.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/strings.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/objects.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/variables.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/programs.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/tips.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/loops.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/user_input.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/conditionals.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/tips.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/arrays.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/iterators.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/hashes.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/address.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/address2.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/sorting.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/address2.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/sorting.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/functions.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes2.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/addressbook.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/features.html
References http://en.wikipedia.org/wiki/Rapid_application_development http://en.wikipedia.org/wiki/Agile_software_development http://en.wikipedia.org/wiki/Yukihiro_Matsumoto http://en.wikipedia.org/wiki/Ruby_%28programming_language%29#Examples http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 http://en.wikipedia.org/wiki/Ruby_on_Rails http://www.google.com/webhp?hl=en#hl=en&source=hp&q=ruby+functional+programming&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=a86c207b1c79523e http://stackoverflow.com/questions/159797/is-ruby-a-functional-language http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/330387 http://stackoverflow.com/questions/546968/when-you-say-ruby-is-reflective-does-this-mainly-refer-to-duck-typing http://www.tutorialspoint.com/ruby/ruby_object_oriented.htm http://www.rubyist.net/~slagell/ruby/oothinking.html http://www.techotopia.com/index.php/Ruby_Object_Oriented_Programming http://d.hatena.ne.jp/shunsuk/20090101/1230816826 http://www.slideshare.net/peter_marklund/ruby-on-rails-101-presentation-slides-for-a-five-day-introductory-course http://picasaweb.google.com/Dikiwinky/Ruby#5116531304417868130 http://articles.slicehost.com/2009/4/7/centos-ruby-on-rails http://www.railstutorial.org/book

More Related Content

PPTX
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
KEY
Mashups with Drupal and QueryPath
PPT
Ruby On Rails Presentation
PDF
React Native custom components
PPT
Jasig Rubyon Rails
PPTX
JRuby in Java Projects
PPT
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Mashups with Drupal and QueryPath
Ruby On Rails Presentation
React Native custom components
Jasig Rubyon Rails
JRuby in Java Projects

What's hot (20)

PDF
Symfony + GraphQL
PPTX
Graphql + Symfony | Александр Демченко | CODEiD
KEY
An Introduction to Ruby on Rails
PDF
Ruby On Rails
PDF
Alive and Well with Java 8
PDF
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
PPTX
Beginners' guide to Ruby on Rails
PPTX
Diving into Java Class Loader
PDF
The Dark Art of Rails Plugins (2008)
PDF
JavaScript - From Birth To Closure
PPTX
Software Uni Conf October 2014
PDF
Laravel and Django and Rails, Oh My!
PPTX
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
PDF
Metaprogramming with javascript
PPTX
SoftwareUniversity seminar fast REST Api with Spring
PPTX
AngularConf2015
PDF
Effective Scala: Programming Patterns
PDF
Ruby Xml Mapping
PDF
Java Libraries You Can't Afford To Miss
Symfony + GraphQL
Graphql + Symfony | Александр Демченко | CODEiD
An Introduction to Ruby on Rails
Ruby On Rails
Alive and Well with Java 8
What's a macro?: Learning by Examples / Scalaのマクロに実用例から触れてみよう!
Beginners' guide to Ruby on Rails
Diving into Java Class Loader
The Dark Art of Rails Plugins (2008)
JavaScript - From Birth To Closure
Software Uni Conf October 2014
Laravel and Django and Rails, Oh My!
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Metaprogramming with javascript
SoftwareUniversity seminar fast REST Api with Spring
AngularConf2015
Effective Scala: Programming Patterns
Ruby Xml Mapping
Java Libraries You Can't Afford To Miss
Ad

Viewers also liked (14)

PPT
Boston Computing Review - Ruby on Rails
PDF
Intro To Swift
PDF
Ruby On Rails - 1. Ruby Introduction
PPT
Ruby on Rails introduction
PPT
Intro To Ror
ZIP
Ruby On Rails Presentation Barcamp Antwerp.Key
PPTX
Intro to Rails and MVC
PPT
Rochester on Rails: Introduction to Ruby
PDF
Introduction to Ruby on Rails
PPT
Introduction To Ruby On Rails
PPT
Introduction to Ruby on Rails
ODP
Introduction to Ruby on Rails
PDF
Web Development with Python and Django
PPTX
Introduction to Ruby on Rails
Boston Computing Review - Ruby on Rails
Intro To Swift
Ruby On Rails - 1. Ruby Introduction
Ruby on Rails introduction
Intro To Ror
Ruby On Rails Presentation Barcamp Antwerp.Key
Intro to Rails and MVC
Rochester on Rails: Introduction to Ruby
Introduction to Ruby on Rails
Introduction To Ruby On Rails
Introduction to Ruby on Rails
Introduction to Ruby on Rails
Web Development with Python and Django
Introduction to Ruby on Rails
Ad

Similar to An Introduction to Ruby on Rails 20100506 (20)

PDF
Connecting the Worlds of Java and Ruby with JRuby
PDF
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
PPT
Ruby On Rails Tutorial
KEY
Supa fast Ruby + Rails
PDF
Getting Started with Rails
KEY
Ruby on Rails survival guide of an aged Java developer
PDF
Introduction to Rails - presented by Arman Ortega
PDF
JRuby, Ruby, Rails and You on the Cloud
PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
PPT
Ruby On Rails Introduction
PDF
RoR 101: Session 2
PDF
Rspec and Capybara Intro Tutorial at RailsConf 2013
PDF
How to Begin to Develop Ruby Core
PDF
Building web framework with Rack
PDF
Ruby on rails探索
PDF
Ruby on Rails
PPTX
Why Ruby?
PPTX
Intro to Ruby on Rails
PDF
Ruby on Rails - Introduction
PPTX
Ruby on Rails : First Mile
Connecting the Worlds of Java and Ruby with JRuby
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Ruby On Rails Tutorial
Supa fast Ruby + Rails
Getting Started with Rails
Ruby on Rails survival guide of an aged Java developer
Introduction to Rails - presented by Arman Ortega
JRuby, Ruby, Rails and You on the Cloud
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Ruby On Rails Introduction
RoR 101: Session 2
Rspec and Capybara Intro Tutorial at RailsConf 2013
How to Begin to Develop Ruby Core
Building web framework with Rack
Ruby on rails探索
Ruby on Rails
Why Ruby?
Intro to Ruby on Rails
Ruby on Rails - Introduction
Ruby on Rails : First Mile

More from Vu Hung Nguyen (20)

PPTX
Co ban horenso - Tai lieu training noi bo
PDF
Funix techtalk: Tự học hiệu quả thời 4.0
PDF
Học cờ cùng con - Nguyễn Vỹ Kỳ Anh [U8]
PDF
Japanese for it bridge engineers
PPTX
Basic IT Project Management Terminologies
PDF
2018 Học cờ cùng con - Nguyễn Vũ Kỳ Anh [U7]
PDF
Làm việc hiệu quả với sếp Nhật (2017)
PDF
Problem Solving Skills (for IT Engineers)
PPTX
Using Shader in cocos2d-x
PPTX
Pham Anh Tu - TK Framework
PDF
My idol: Magnus Carlsen vs. Ky Anh 2G1 NGS Newton
PDF
Basic advanced scrum framework
PDF
FPT Univ. Talkshow IT khong chi la lap trinh
PDF
Basic & Advanced Scrum Framework
PDF
Agile Vietnam Conference 2016: Recap
PDF
IT Public Speaking Guidelines
PDF
Kanban: Cơ bản và Nâng cao
PDF
Học cờ vua cùng con Nguyễn Vũ Kỳ Anh (U6)
PPTX
Fuji Technology Workshop: Learning Skills
PDF
Anti patterns in it project management
Co ban horenso - Tai lieu training noi bo
Funix techtalk: Tự học hiệu quả thời 4.0
Học cờ cùng con - Nguyễn Vỹ Kỳ Anh [U8]
Japanese for it bridge engineers
Basic IT Project Management Terminologies
2018 Học cờ cùng con - Nguyễn Vũ Kỳ Anh [U7]
Làm việc hiệu quả với sếp Nhật (2017)
Problem Solving Skills (for IT Engineers)
Using Shader in cocos2d-x
Pham Anh Tu - TK Framework
My idol: Magnus Carlsen vs. Ky Anh 2G1 NGS Newton
Basic advanced scrum framework
FPT Univ. Talkshow IT khong chi la lap trinh
Basic & Advanced Scrum Framework
Agile Vietnam Conference 2016: Recap
IT Public Speaking Guidelines
Kanban: Cơ bản và Nâng cao
Học cờ vua cùng con Nguyễn Vũ Kỳ Anh (U6)
Fuji Technology Workshop: Learning Skills
Anti patterns in it project management

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
1. Introduction to Computer Programming.pptx
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation theory and applications.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Approach and Philosophy of On baking technology
PDF
August Patch Tuesday
MIND Revenue Release Quarter 2 2025 Press Release
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Univ-Connecticut-ChatGPT-Presentaion.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
1. Introduction to Computer Programming.pptx
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
Spectroscopy.pptx food analysis technology
Encapsulation theory and applications.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Empathic Computing: Creating Shared Understanding
A comparative study of natural language inference in Swahili using monolingua...
Digital-Transformation-Roadmap-for-Companies.pptx
Assigned Numbers - 2025 - Bluetooth® Document
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Heart disease approach using modified random forest and particle swarm optimi...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Approach and Philosophy of On baking technology
August Patch Tuesday

An Introduction to Ruby on Rails 20100506

  • 1. An INTRODUCTION to Ruby on Rails Nguyen Vu Hung [email_address] 2010/05/05
  • 2. Agenda Ruby – The language. Ruby on Rails
  • 3. Ruby – The language Made in Japan Creator: まつもとゆきひろ Influenced by Perl, Smalltalk, Eiffel and Lisp. Multi-paradigm programming language: Functional, Object oriented, Imperative and Reflective. Dynamic and automatic memory management. Written in C Single-pass interpreted language (CLI, Interactive Ruby Shell)
  • 4. まつもとゆきひろ Yukihiro Matsumoto 松本行弘 Born 1965 Computer scientist Programmer Compiler
  • 5. Ruby influenced by Perl CLI Scripting language Simple Smalltalk Object-oriented Dynamically typed Reflective Can observe and modify its own structure and behavior Eiffel Lisp Originally specified in 1958 Fully parenthesized syntax
  • 6. Functional language Emphasizes the application of functions. Everything is a function. class Array def iterate (code) self.each_with_index do |n, i| self[i] = code.call(n) end end end array = [1, 2, 3, 4] array. iterate (l ambda { |n| n ** 2 }) puts array.inspect # => [1, 4, 9, 16]
  • 7. Object oriented Similar to Java, PHP, Perl end end Point.new(@x*scalar, @y*scalar) def *(scalar) # To perform scalar multiplication Point.new(-@x, -@y) end def -@ # Define unary minus to negate x and y Point.new(@x + other.x, @y + other.y) end def +(other) # Define + to do vector addition @x,@y = x, y end Class Point attr_reader :x, :y # Define accessor methods
  • 9. Reflective Language TBD TBD: Java Reflection.
  • 10. Ruby on Rails Open source web application framework MIT license. Used with Agile development methodology Rail architecture A MVC model Scaffolding : Automatically creates a skeleton of a basic website. WEBrick. Mongrel: Web servers. Rake: A build system. Test-Driven ActiveRecord An object-relational mapping system for database access
  • 12. Rails architecture: 3-tier, N-tier? http://picasaweb.google.com/Dikiwinky/Ruby#5116531304417868130
  • 13. Rails architecture: MVC Q: Where is M, V and C?
  • 14. Ruby Agile Development Iterative development. Self organized. Cross-functional team. Leadership philosophy: No real leader. Frequent inspection and adaptation. Allow high-quality. Rapid delivery.
  • 15. Ruby Scaffolding Generate source as needed-> Create a database (cookbook) Configure /config/database.yml Generate source code: ruby script/generate scaffold Recipe title:string chef:string instructions:text
  • 16. exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/recipes exists app/views/layouts/ exists test/functional/ exists test/unit/ exists public/stylesheets/ create app/views/recipes/index.html.erb create app/views/recipes/show.html.erb create app/views/recipes/new.html.erb create app/views/recipes/edit.html.erb create app/views/layouts/recipes.html.erb create public/stylesheets/scaffold.css create app/controllers/recipes_controller.rb create test/functional/recipes_controller_test.rb create app/helpers/recipes_helper.rb route map.resources :recipes dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/recipe.rb create test/unit/recipe_test.rb create test/fixtures/recipes.yml create db/migrate create db/migrate/20080614192220_create_recipes.rb
  • 17. exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/recipes exists app/views/layouts/ exists test/functional/ exists test/unit/ exists public/stylesheets/ create app/views/recipes/index.html.erb create app/views/recipes/show.html.erb create app/views/recipes/new.html.erb create app/views/recipes/edit.html.erb create app/views/layouts/recipes.html.erb create public/stylesheets/scaffold.css create app/controllers/recipes_controller.rb create test/functional/recipes_controller_test.rb create app/helpers/recipes_helper.rb route map.resources :recipes dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/recipe.rb create test/unit/recipe_test.rb create test/fixtures/recipes.yml create db/migrate create db/migrate/20080614192220_create_recipes.rb
  • 18. Ruby, Rails Installation CentOS 5: yum install -y ruby yum install -y ruby-devel ruby-docs ruby-ri ruby-irb ruby-rdoc tar xzvf rubygems-1.3.1.tgz cd rubygems sudo ruby setup.rb sudo gem update sudo gem install rails Windows http://rubyonrails.org/download
  • 19. Gems installed on Server 123 [vuhung@vinicorp ~]$ sudo gem list *** LOCAL GEMS *** actionmailer (2.3.5, 2.2.2) actionpack (2.3.5, 2.2.2) activerecord (2.3.5, 2.2.2) activeresource (2.3.5, 2.2.2) activesupport (2.3.5, 2.2.2) eventmachine (0.12.10) fastthread (1.0.7) htmlentities (4.2.0) json (1.2.0) juggernaut (0.5.8) passenger (2.2.9) rack (1.0.1) rails (2.3.5, 2.2.2) rake (0.8.7
  • 20. Rake A software building tool (automatically). Written in Ruby. Configuration file: Rakefiles, ruby syntax. Common task can be done by ruby blocks (make cannot). Rake GNU make
  • 21. Test-Driven Development Test first Write test-cases first. Automatic test cases generation. Short development circle. Regression test. Automated unit test. “Test” folder generated by Rake.
  • 22. A short tutorial [vuhung@vinicorp ~]$ irb irb(main):001:0> puts "Hello Worlds" Hello Worlds => nil irb(main):002:0> 3+2 => 5 irb(main):003:0> 3*2 => 6 irb(main):004:0> 3**2 => 9 irb(main):005:0> Math.sqrt(9) => 3.0 irb(main):006:0> a = 3**2 => 9 irb(main):007:0> b = 4**2 => 16 irb(main):008:0> Math.sqrt(a+b) => 5.0 irb(main):009:0>
  • 23. Redmine Web based Project Management Application. Written in Ruby on Rails GPL v2 licensed (free software). Rake as build system. Gems WEBrick Plenty of plugins available. Stable since 2009/11 to date. Supports various DB back-end after Rails.
  • 24. Redmine Folder Structure (2) ls -1 /var/www/html/redmine/redmine-0.8.7 app config db doc extra files lang lib log public Rakefile script start_redmine.sh test tmp vendor
  • 25.  
  • 26. TODO http://www.railstutorial.org/book#top http://www.railstutorial.org/chapters/a-demo-app#top http://www.railstutorial.org/chapters/static-pages#top http://www.railstutorial.org/chapters/rails-flavored-ruby#top http://www.railstutorial.org/chapters/filling-in-the-layout#top http://www.railstutorial.org/chapters/modeling-and-viewing-users-one#top http://www.railstutorial.org/chapters/modeling-and-viewing-users-two#top http://www.railstutorial.org/chapters/sign-up#top http://www.railstutorial.org/chapters/sign-in-sign-out#top http://www.railstutorial.org/chapters/updating-showing-and-deleting-users#top
  • 27. TODO http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/strings.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/strings.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/objects.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/variables.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/programs.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_01/tips.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/loops.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/user_input.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/conditionals.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_02/tips.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/arrays.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/iterators.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/hashes.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/address.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/address2.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/sorting.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/address2.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_03/sorting.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/functions.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/classes2.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/addressbook.html http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/features.html
  • 28. References http://en.wikipedia.org/wiki/Rapid_application_development http://en.wikipedia.org/wiki/Agile_software_development http://en.wikipedia.org/wiki/Yukihiro_Matsumoto http://en.wikipedia.org/wiki/Ruby_%28programming_language%29#Examples http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 http://en.wikipedia.org/wiki/Ruby_on_Rails http://www.google.com/webhp?hl=en#hl=en&source=hp&q=ruby+functional+programming&aq=f&aqi=&aql=&oq=&gs_rfai=&fp=a86c207b1c79523e http://stackoverflow.com/questions/159797/is-ruby-a-functional-language http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/330387 http://stackoverflow.com/questions/546968/when-you-say-ruby-is-reflective-does-this-mainly-refer-to-duck-typing http://www.tutorialspoint.com/ruby/ruby_object_oriented.htm http://www.rubyist.net/~slagell/ruby/oothinking.html http://www.techotopia.com/index.php/Ruby_Object_Oriented_Programming http://d.hatena.ne.jp/shunsuk/20090101/1230816826 http://www.slideshare.net/peter_marklund/ruby-on-rails-101-presentation-slides-for-a-five-day-introductory-course http://picasaweb.google.com/Dikiwinky/Ruby#5116531304417868130 http://articles.slicehost.com/2009/4/7/centos-ruby-on-rails http://www.railstutorial.org/book