SlideShare a Scribd company logo
Ruby on RailsAn IntroductionSarah AllenBlazing Cloud
Ruby on Rails historyRuby on Rails was extracted from 37signals’ Basecamp by David Heinemeier Hansson (DHH)July 2004: first released as open source Feb 2005: first external commit rights Oct 2007: ships with Mac OS X v10.5 "Leopard”
Rails Philosophy Opinionated Convention over configuration DRY (Don't Repeat Yourself)less code means it's easier to maintain & modify Test Driven Development (TDD) Minimal code - maximal effect
What you will learnRubyLanguage conceptsLanguage syntaxCommon patternsRails Framework: creating web applicationsScaffoldModel, View, Controllers, RoutesSQL Queries, log files and debuggingAssociations
How you will learnExploration: experiment, playTest-Driven Development (TDD)Initially as a learning methodologyLater as a development methodologyAsk questionsLearn to find your own answers
Class StructureTalkLive Coding DemonstrationsIn-class coding
Prerequistes	Core dependencies: Ruby, Rails, DBTools: vcs, IDE, test frameworks, deployment
Core Dependencies	RubyRailsRakeDatabase
Ruby	Rails is a framework written in the Ruby language.Great Rails developers are great Ruby developers.
The Ruby LanguageOriginally  by Yukihiro "Matz" Matsumoto“Ruby is designed for programmer productivity and fun, following the principles of good user interface design. He stresses that systems design needs to emphasize human, rather than computer, needs.”http://en.wikipedia.org/wiki/Ruby_(programming_language)#HistoryRuby 1.0 was released in 1996.
Ruby	ruby -v1.8.6 or 1.8.7
Ruby Versionsruby -v1.8.6 – most common1.8.7 – some 1.9 features, very compatible1.9.1 – latest version, many VMs, Rails 2.3YARV (yet another Ruby VM) faster than MRIJRuby (Java)Rubinius (pure ruby) IronRuby (.NET)MacRuby, HotCocoaHotRuby/RubyJS (Flash/Javascript)
Ruby	GemsA gem is a ruby library.gem –v   1.3.5 or highergem list[sudo] gem install
RailsRails is distributed as a Ruby gem.gem list rails   2.3.4 or higher[sudo] gem install rails
rakeRake is “make” for Ruby.  Rails requires rake.Rake is distrubted as a gem.gem list rake0.8.7 or higher[sudo] gem install rake
DatabaseSQLite for class with sqlite3-ruby gemOther databases:MySQLPostgreSQLOracleSQL ServerSyBaseDB2
Tools	Source Code Control with GitTerminal / git bash on windowsEditor / IDETest FrameworksHeroku for Easy Deployment
gitGit is for source code control.which git (mac, unix)git bash on windowsWhy Git?Most Ruby and Rails developers use gitEco-system of toolsModern Source Code Control
Ruby On Rails Intro
command lineMac/Unix TerminalGitBash on Windows
Editor / IDERubyMineTextMate (Mac-only)Komodo (free)
Test Frameworksgem list rspecrspec (1.3.0)rspec-rails (1.3.2)gem list cucumbercucumber (0.6.2)cucumber-rails (0.2.4)
HerokuSimple cloud hostingWeb sign-up for free account: heroku.com	[sudo] gem install heroku
Prerequisites	Core dependenciesRubyRuby GemsRails (gem)RakeDatabaseToolsGitTerminal / git bash on windowsTest Frameworksrspec, rspec-railscucumber, cucumber-railsHeroku (for deployment)
Let’s Get Started
Lets get startedIRB: InteractiveRuBy>> 4>> 4 + 4
Everything is an object“test”.upcase“test”.class“test”.methods
Everything evaluates to something2 + 2(2+2).zero?
Methods are Messagesthing.do(4)thing.do 4thing.send “do”, 4
Operators are Methodsthing.do 4thing.do(4)thing.send “do”, 41 + 21.+(2)1.send "+", 2
Defining ClassesLet’s write some code!
Test-First LearningSimilar methodology to TDDwith a different purpose and workflowTeacher writes the testStudent implements the code
Test-Driven DevelopmentDesignFocus / Project ManagementCreation of Tests
Introduction to RspecDescribe the featureVerify expectation
Ruby On Rails Intro
ScaffoldModelapp/models/person.rbdb/migrate/20090611073227_create_people.rb4 viewsapp/views/people/index.html.erbapp/views/people/show.html.erbapp/views/people/new.html.erbapp/views/people/edit.html.erbControllerapp/controllers/people_controller.rbroute map.resources :people
MVCModel: ActiveRecordRepresents what is in the databaseView: ActionView, erbModel rendered as HTMLController: ActionControllerReceives HTTP actions (GET, POST, PUT, DELETE)Decides what to do, typically rendering a view
MVC
views<% @people.each do |person| %><tr>	<td><%=h person.first_name %></td>    <td><%=h person.last_name %></td>    <td><%=h person.present %></td></tr><% end %>
View Exercise1. On the main people page  	a. Change “Listing people” to “My Class List”  	b. Remove the “Present” column  2. When you click “show,” the page should read “Joy McDonald was not present at class”      or “Bob Smith was present at class”  
ActiveRecordp = new Personp = new Person(:first => "May", :last => "Fong")p.savep.save!Person.create(:first => "May", :last => "Fong")Person.create!(:first => "May", :last => "Fong")
Safe from SQL injectionclass User < ActiveRecord::Base     def self.authenticate_unsafely(user_name, password)       find(:first, :conditions =>               "user_name = '#{user_name}' AND password = '#{password}'")     end     def self.authenticate_safely(user_name, password)       find(:first, :conditions =>              [ "user_name = ? AND password = ?", user_name, password ])     end     def self.authenticate_safely_simply(user_name, password)       find(:first, :conditions =>             { :user_name => user_name, :password => password })     end   end

More Related Content

PPTX
Drupal by fire
PDF
Ruby On Rails Introduction
PDF
When To Use Ruby On Rails
ODP
Ruby on Rails
PPT
JavaScript
PPTX
SharePoint and jQuery Essentials
PPT
jQuery introduction
PDF
Web Development with Python and Django
Drupal by fire
Ruby On Rails Introduction
When To Use Ruby On Rails
Ruby on Rails
JavaScript
SharePoint and jQuery Essentials
jQuery introduction
Web Development with Python and Django

What's hot (20)

PPTX
How dojo works
PDF
Scalable web application architecture
PDF
JavaScript-Core
PDF
HTML5 Essentials
PDF
Killing the Angle Bracket
PPT
루비가 얼랭에 빠진 날
PDF
Getting Started with Rails
PPT
Web performance essentials - Goodies
PPTX
A Blink Into The Rails Magic
PDF
jQuery Features to Avoid
PPTX
Unobtrusive javascript with jQuery
PPT
Grails Introduction - IJTC 2007
PPTX
Django Architecture Introduction
PDF
Component-Oriented Web Development with Dart
PDF
React for Beginners
PDF
Introduction to JavaScript
PDF
JavaScript and BOM events
PDF
jQuery Essentials
PDF
遇見 Ruby on Rails
How dojo works
Scalable web application architecture
JavaScript-Core
HTML5 Essentials
Killing the Angle Bracket
루비가 얼랭에 빠진 날
Getting Started with Rails
Web performance essentials - Goodies
A Blink Into The Rails Magic
jQuery Features to Avoid
Unobtrusive javascript with jQuery
Grails Introduction - IJTC 2007
Django Architecture Introduction
Component-Oriented Web Development with Dart
React for Beginners
Introduction to JavaScript
JavaScript and BOM events
jQuery Essentials
遇見 Ruby on Rails
Ad

Viewers also liked (10)

PDF
Ruby Nuby Session - Rails Intro
ODP
Intro to Ruby on Rails - BCC 2014
KEY
Supa fast Ruby + Rails
PDF
Ruby on Rails Workshop
PDF
D-Talk: What's awesome about Ruby 2.x and Rails 4
PDF
Intro to rails 2_kg_edited
PDF
Rails MVC Architecture
PPTX
Intro to Rails and MVC
PPT
MVC Demystified: Essence of Ruby on Rails
PDF
Ruby and Rails intro
Ruby Nuby Session - Rails Intro
Intro to Ruby on Rails - BCC 2014
Supa fast Ruby + Rails
Ruby on Rails Workshop
D-Talk: What's awesome about Ruby 2.x and Rails 4
Intro to rails 2_kg_edited
Rails MVC Architecture
Intro to Rails and MVC
MVC Demystified: Essence of Ruby on Rails
Ruby and Rails intro
Ad

Similar to Ruby On Rails Intro (20)

PDF
Ruby on Rails Presentation
PPTX
Why Ruby?
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
PDF
Introduction to Rails - presented by Arman Ortega
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
PDF
Connecting the Worlds of Java and Ruby with JRuby
KEY
An introduction to Rails 3
PPT
Ruby On Rails
PDF
Lecture #5 Introduction to rails
PDF
Introduction to Rails by Evgeniy Hinyuk
KEY
Intro to Ruby on Rails
PPTX
Rubyonrails 120409061835-phpapp02
PPT
PPTX
Code for Startup MVP (Ruby on Rails) Session 2
PPT
Ruby On Rails Seminar Basis Softexpo Feb2010
PDF
Ruby on Rails : 簡介與入門
KEY
Ruby On Rails Overview
PPT
Ruby on Rails: Building Web Applications Is Fun Again!
PPT
An introduction-to-ruby-on-rails
PPT
An Introduction to Ruby on Rails 20100506
Ruby on Rails Presentation
Why Ruby?
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Introduction to Rails - presented by Arman Ortega
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Connecting the Worlds of Java and Ruby with JRuby
An introduction to Rails 3
Ruby On Rails
Lecture #5 Introduction to rails
Introduction to Rails by Evgeniy Hinyuk
Intro to Ruby on Rails
Rubyonrails 120409061835-phpapp02
Code for Startup MVP (Ruby on Rails) Session 2
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby on Rails : 簡介與入門
Ruby On Rails Overview
Ruby on Rails: Building Web Applications Is Fun Again!
An introduction-to-ruby-on-rails
An Introduction to Ruby on Rails 20100506

More from Sarah Allen (20)

PDF
Internet security: a landscape of unintended consequences
PPTX
RTMP: how did we get to now? (Demuxed 2019)
PDF
Communication is a Technical Skill
PPTX
Improving Federal Government Services
PPTX
Transparency Wins
PPTX
A Short History of Computers
PPTX
Making Software Fun
PPTX
Power of Transparency
PPTX
Designing for Fun
PDF
Ruby in the US Government for Ruby World Conference
PDF
Identities of Dead People
PDF
Let's pretend
PDF
3 Reasons Not to Use Ruby
PDF
Ruby Nation: Why no haz Ruby?
PDF
Why no ruby in gov?
PDF
People Patterns or What I learned from Toastmasters
PDF
Blazing Cloud: Agile Product Development
PDF
Crowdsourced Transcription Landscape
PDF
Lessons Learned Future Thoughts
PDF
Mobile Web Video
Internet security: a landscape of unintended consequences
RTMP: how did we get to now? (Demuxed 2019)
Communication is a Technical Skill
Improving Federal Government Services
Transparency Wins
A Short History of Computers
Making Software Fun
Power of Transparency
Designing for Fun
Ruby in the US Government for Ruby World Conference
Identities of Dead People
Let's pretend
3 Reasons Not to Use Ruby
Ruby Nation: Why no haz Ruby?
Why no ruby in gov?
People Patterns or What I learned from Toastmasters
Blazing Cloud: Agile Product Development
Crowdsourced Transcription Landscape
Lessons Learned Future Thoughts
Mobile Web Video

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Spectroscopy.pptx food analysis technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Cloud computing and distributed systems.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Spectroscopy.pptx food analysis technology
Network Security Unit 5.pdf for BCA BBA.
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Building Integrated photovoltaic BIPV_UPV.pdf
Cloud computing and distributed systems.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
“AI and Expert System Decision Support & Business Intelligence Systems”
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced methodologies resolving dimensionality complications for autism neur...
Review of recent advances in non-invasive hemoglobin estimation

Ruby On Rails Intro