SlideShare una empresa de Scribd logo
1 de 42
Ruby on RailsAn Introduction Sarah Allen Blazing Cloud
Ruby on Rails history Ruby 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 learn Ruby Language concepts Language syntax Common patterns Rails Framework: creating web applications Scaffold Model, View, Controllers, Routes SQL Queries, log files and debugging Associations
How you will learn Exploration: experiment, play Test-Driven Development (TDD) Initially as a learning methodology Later as a development methodology Ask questions Learn to find your own answers
Class Structure Talk Live Coding Demonstrations In-class coding
Prerequistes	 Core dependencies: Ruby, Rails, DB Tools: vcs, IDE, test frameworks, deployment
Core Dependencies	 Ruby Rails Rake Database
Ruby	 Rails is a framework  written in the Ruby language. Great Rails developers  are great Ruby developers.
The Ruby Language Originally  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)#History Ruby 1.0 was released in 1996.
Ruby	 ruby -v 1.8.6 or 1.8.7
Ruby Versions ruby -v 1.8.6 – most common 1.8.7 – some 1.9 features, very compatible 1.9.1 – latest version, many VMs, Rails 2.3 YARV (yet another Ruby VM) faster than MRI JRuby (Java) Rubinius (pure ruby)  IronRuby (.NET) MacRuby, HotCocoa HotRuby/RubyJS (Flash/Javascript)
Ruby	Gems A gem is a ruby library. gem –v   1.3.5 or higher gem list[sudo] gem install
Rails Rails is distributed as a Ruby gem. gem list rails   2.3.4 or higher [sudo] gem install rails
rake Rake is “make” for Ruby.  Rails requires rake. Rake is distrubted as a gem. gem list rake0.8.7 or higher [sudo] gem install rake
Database SQLite for class with sqlite3-ruby gem Other databases: MySQL PostgreSQL Oracle SQL Server SyBase DB2
Tools	 Source Code Control with Git Terminal / git bash on windows Editor / IDE Test Frameworks Heroku for Easy Deployment
git Git is for source code control. which git (mac, unix) git bash on windows Why Git? Most Ruby and Rails developers use git Eco-system of tools Modern Source Code Control
command line Mac/Unix Terminal GitBash on Windows
Editor / IDE RubyMine TextMate (Mac-only) Komodo (free)
Test Frameworks gem list rspec rspec (1.3.0) rspec-rails (1.3.2) gem list cucumber cucumber (0.6.2) cucumber-rails (0.2.4)
Heroku Simple cloud hosting Web sign-up for free account: heroku.com 	[sudo] gem install heroku
Prerequisites	 Core dependencies Ruby Ruby Gems Rails (gem) Rake Database Tools Git Terminal / git bash on windows Test Frameworks rspec, rspec-rails cucumber, cucumber-rails Heroku (for deployment)
Let’s Get Started
Lets get started IRB: InteractiveRuBy >> 4 >> 4 + 4
Everything is an object “test”.upcase “test”.class “test”.methods
Everything evaluates to something 2 + 2 (2+2).zero?
Methods are Messages thing.do(4) thing.do 4 thing.send “do”, 4
Operators are Methods thing.do 4 thing.do(4) thing.send “do”, 4 1 + 2 1.+(2) 1.send "+", 2
Defining Classes Let’s write some code!
Test-First Learning Similar methodology to TDDwith a different purpose and workflow Teacher writes the test Student implements the code
Test-Driven Development Design Focus / Project Management Creation of Tests
Introduction to Rspec Describe the feature Verify expectation
Scaffold Model app/models/person.rb db/migrate/20090611073227_create_people.rb 4 views app/views/people/index.html.erb app/views/people/show.html.erb app/views/people/new.html.erb app/views/people/edit.html.erb Controller app/controllers/people_controller.rb route map.resources :people
MVC Model: ActiveRecord Represents what is in the database View: ActionView, erb Model rendered as HTML Controller: ActionController Receives 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 Exercise 1. 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”  
ActiveRecord p = new Person p = new Person(:first => "May", :last => "Fong") p.save p.save! Person.create(:first => "May", :last => "Fong") Person.create!(:first => "May", :last => "Fong")
Safe from SQL injection class 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

Más contenido relacionado

La actualidad más candente

How dojo works
How dojo worksHow dojo works
How dojo worksAmit Tyagi
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracketjnewmanux
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날Sukjoon Kim
 
Getting Started with Rails
Getting Started with RailsGetting Started with Rails
Getting Started with RailsBasayel Said
 
Web performance essentials - Goodies
Web performance essentials - GoodiesWeb performance essentials - Goodies
Web performance essentials - GoodiesJerry Emmanuel
 
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)Clément Wehrung
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQueryAngel Ruiz
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Guillaume Laforge
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture IntroductionHaiqi Chen
 
Component-Oriented Web Development with Dart
Component-Oriented Web Development with DartComponent-Oriented Web Development with Dart
Component-Oriented Web Development with DartC4Media
 

La actualidad más candente (20)

How dojo works
How dojo worksHow dojo works
How dojo works
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날루비가 얼랭에 빠진 날
루비가 얼랭에 빠진 날
 
Getting Started with Rails
Getting Started with RailsGetting Started with Rails
Getting Started with Rails
 
Web performance essentials - Goodies
Web performance essentials - GoodiesWeb performance essentials - Goodies
Web performance essentials - Goodies
 
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
ePub 3, HTML 5 & CSS 3 (+ Fixed-Layout)
 
A Blink Into The Rails Magic
A Blink Into The Rails MagicA Blink Into The Rails Magic
A Blink Into The Rails Magic
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Component-Oriented Web Development with Dart
Component-Oriented Web Development with DartComponent-Oriented Web Development with Dart
Component-Oriented Web Development with Dart
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

Destacado

Ruby Nuby Session - Rails Intro
Ruby Nuby Session - Rails IntroRuby Nuby Session - Rails Intro
Ruby Nuby Session - Rails IntroJohn Barton
 
Intro to Ruby on Rails - BCC 2014
Intro to Ruby on Rails - BCC 2014Intro to Ruby on Rails - BCC 2014
Intro to Ruby on Rails - BCC 2014chrischattin
 
Ruby on Rails Workshop
Ruby on Rails WorkshopRuby on Rails Workshop
Ruby on Rails WorkshopYos Riady
 
D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4Jan Berdajs
 
Rails MVC Architecture
Rails MVC ArchitectureRails MVC Architecture
Rails MVC ArchitectureMasato TADA
 
Intro to Rails and MVC
Intro to Rails and MVCIntro to Rails and MVC
Intro to Rails and MVCSarah Allen
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Ruby and Rails intro
Ruby and Rails introRuby and Rails intro
Ruby and Rails introNuno Silva
 

Destacado (10)

Ruby Nuby Session - Rails Intro
Ruby Nuby Session - Rails IntroRuby Nuby Session - Rails Intro
Ruby Nuby Session - Rails Intro
 
Intro to Ruby on Rails - BCC 2014
Intro to Ruby on Rails - BCC 2014Intro to Ruby on Rails - BCC 2014
Intro to Ruby on Rails - BCC 2014
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Ruby on Rails Workshop
Ruby on Rails WorkshopRuby on Rails Workshop
Ruby on Rails Workshop
 
D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4D-Talk: What's awesome about Ruby 2.x and Rails 4
D-Talk: What's awesome about Ruby 2.x and Rails 4
 
Intro to rails 2_kg_edited
Intro to rails 2_kg_editedIntro to rails 2_kg_edited
Intro to rails 2_kg_edited
 
Rails MVC Architecture
Rails MVC ArchitectureRails MVC Architecture
Rails MVC Architecture
 
Intro to Rails and MVC
Intro to Rails and MVCIntro to Rails and MVC
Intro to Rails and MVC
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Ruby and Rails intro
Ruby and Rails introRuby and Rails intro
Ruby and Rails intro
 

Similar a Ruby On Rails Intro

Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
Starting with PHP and Web devepolment
Starting with PHP and Web devepolmentStarting with PHP and Web devepolment
Starting with PHP and Web devepolmentRajib Ahmed
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On RailsSteve Keener
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Ruby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupRuby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupJose de Leon
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the restgeorge.james
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Railselpizoch
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 

Similar a Ruby On Rails Intro (20)

Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
Starting with PHP and Web devepolment
Starting with PHP and Web devepolmentStarting with PHP and Web devepolment
Starting with PHP and Web devepolment
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On Rails
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Ruby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupRuby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User Group
 
Web Development Environments: Choose the best or go with the rest
Web Development Environments:  Choose the best or go with the restWeb Development Environments:  Choose the best or go with the rest
Web Development Environments: Choose the best or go with the rest
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Dev streams2
Dev streams2Dev streams2
Dev streams2
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby on Rails
Ruby on Rails Ruby on Rails
Ruby on Rails
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 

Más de Sarah Allen

Internet security: a landscape of unintended consequences
Internet security: a landscape of unintended consequencesInternet security: a landscape of unintended consequences
Internet security: a landscape of unintended consequencesSarah Allen
 
RTMP: how did we get to now? (Demuxed 2019)
RTMP: how did we get to now? (Demuxed 2019)RTMP: how did we get to now? (Demuxed 2019)
RTMP: how did we get to now? (Demuxed 2019)Sarah Allen
 
Communication is a Technical Skill
Communication is a Technical SkillCommunication is a Technical Skill
Communication is a Technical SkillSarah Allen
 
Improving Federal Government Services
Improving Federal Government ServicesImproving Federal Government Services
Improving Federal Government ServicesSarah Allen
 
Transparency Wins
Transparency WinsTransparency Wins
Transparency WinsSarah Allen
 
A Short History of Computers
A Short History of ComputersA Short History of Computers
A Short History of ComputersSarah Allen
 
Making Software Fun
Making Software FunMaking Software Fun
Making Software FunSarah Allen
 
Power of Transparency
Power of TransparencyPower of Transparency
Power of TransparencySarah Allen
 
Designing for Fun
Designing for FunDesigning for Fun
Designing for FunSarah Allen
 
Ruby in the US Government for Ruby World Conference
Ruby in the US Government for Ruby World ConferenceRuby in the US Government for Ruby World Conference
Ruby in the US Government for Ruby World ConferenceSarah Allen
 
Identities of Dead People
Identities of Dead PeopleIdentities of Dead People
Identities of Dead PeopleSarah Allen
 
3 Reasons Not to Use Ruby
3 Reasons Not to Use Ruby 3 Reasons Not to Use Ruby
3 Reasons Not to Use Ruby Sarah Allen
 
Ruby Nation: Why no haz Ruby?
Ruby Nation: Why no haz Ruby?Ruby Nation: Why no haz Ruby?
Ruby Nation: Why no haz Ruby?Sarah Allen
 
Why no ruby in gov?
Why no ruby in gov?Why no ruby in gov?
Why no ruby in gov?Sarah Allen
 
People Patterns or What I learned from Toastmasters
People Patterns or What I learned from ToastmastersPeople Patterns or What I learned from Toastmasters
People Patterns or What I learned from ToastmastersSarah Allen
 
Blazing Cloud: Agile Product Development
Blazing Cloud: Agile Product DevelopmentBlazing Cloud: Agile Product Development
Blazing Cloud: Agile Product DevelopmentSarah Allen
 
Crowdsourced Transcription Landscape
Crowdsourced Transcription LandscapeCrowdsourced Transcription Landscape
Crowdsourced Transcription LandscapeSarah Allen
 
Lessons Learned Future Thoughts
Lessons Learned Future ThoughtsLessons Learned Future Thoughts
Lessons Learned Future ThoughtsSarah Allen
 
Mobile Web Video
Mobile Web VideoMobile Web Video
Mobile Web VideoSarah Allen
 

Más de Sarah Allen (20)

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

Último

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 

Último (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 

Ruby On Rails Intro

  • 1. Ruby on RailsAn Introduction Sarah Allen Blazing Cloud
  • 2. Ruby on Rails history Ruby 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”
  • 3. 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
  • 4. What you will learn Ruby Language concepts Language syntax Common patterns Rails Framework: creating web applications Scaffold Model, View, Controllers, Routes SQL Queries, log files and debugging Associations
  • 5. How you will learn Exploration: experiment, play Test-Driven Development (TDD) Initially as a learning methodology Later as a development methodology Ask questions Learn to find your own answers
  • 6. Class Structure Talk Live Coding Demonstrations In-class coding
  • 7. Prerequistes Core dependencies: Ruby, Rails, DB Tools: vcs, IDE, test frameworks, deployment
  • 8. Core Dependencies Ruby Rails Rake Database
  • 9. Ruby Rails is a framework written in the Ruby language. Great Rails developers are great Ruby developers.
  • 10. The Ruby Language Originally 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)#History Ruby 1.0 was released in 1996.
  • 11. Ruby ruby -v 1.8.6 or 1.8.7
  • 12. Ruby Versions ruby -v 1.8.6 – most common 1.8.7 – some 1.9 features, very compatible 1.9.1 – latest version, many VMs, Rails 2.3 YARV (yet another Ruby VM) faster than MRI JRuby (Java) Rubinius (pure ruby) IronRuby (.NET) MacRuby, HotCocoa HotRuby/RubyJS (Flash/Javascript)
  • 13. Ruby Gems A gem is a ruby library. gem –v 1.3.5 or higher gem list[sudo] gem install
  • 14. Rails Rails is distributed as a Ruby gem. gem list rails 2.3.4 or higher [sudo] gem install rails
  • 15. rake Rake is “make” for Ruby. Rails requires rake. Rake is distrubted as a gem. gem list rake0.8.7 or higher [sudo] gem install rake
  • 16. Database SQLite for class with sqlite3-ruby gem Other databases: MySQL PostgreSQL Oracle SQL Server SyBase DB2
  • 17. Tools Source Code Control with Git Terminal / git bash on windows Editor / IDE Test Frameworks Heroku for Easy Deployment
  • 18. git Git is for source code control. which git (mac, unix) git bash on windows Why Git? Most Ruby and Rails developers use git Eco-system of tools Modern Source Code Control
  • 19.
  • 20. command line Mac/Unix Terminal GitBash on Windows
  • 21. Editor / IDE RubyMine TextMate (Mac-only) Komodo (free)
  • 22. Test Frameworks gem list rspec rspec (1.3.0) rspec-rails (1.3.2) gem list cucumber cucumber (0.6.2) cucumber-rails (0.2.4)
  • 23. Heroku Simple cloud hosting Web sign-up for free account: heroku.com [sudo] gem install heroku
  • 24. Prerequisites Core dependencies Ruby Ruby Gems Rails (gem) Rake Database Tools Git Terminal / git bash on windows Test Frameworks rspec, rspec-rails cucumber, cucumber-rails Heroku (for deployment)
  • 26. Lets get started IRB: InteractiveRuBy >> 4 >> 4 + 4
  • 27. Everything is an object “test”.upcase “test”.class “test”.methods
  • 28. Everything evaluates to something 2 + 2 (2+2).zero?
  • 29. Methods are Messages thing.do(4) thing.do 4 thing.send “do”, 4
  • 30. Operators are Methods thing.do 4 thing.do(4) thing.send “do”, 4 1 + 2 1.+(2) 1.send "+", 2
  • 31. Defining Classes Let’s write some code!
  • 32. Test-First Learning Similar methodology to TDDwith a different purpose and workflow Teacher writes the test Student implements the code
  • 33. Test-Driven Development Design Focus / Project Management Creation of Tests
  • 34. Introduction to Rspec Describe the feature Verify expectation
  • 35.
  • 36. Scaffold Model app/models/person.rb db/migrate/20090611073227_create_people.rb 4 views app/views/people/index.html.erb app/views/people/show.html.erb app/views/people/new.html.erb app/views/people/edit.html.erb Controller app/controllers/people_controller.rb route map.resources :people
  • 37. MVC Model: ActiveRecord Represents what is in the database View: ActionView, erb Model rendered as HTML Controller: ActionController Receives HTTP actions (GET, POST, PUT, DELETE) Decides what to do, typically rendering a view
  • 38. MVC
  • 39. 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 %>
  • 40. View Exercise 1. 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”  
  • 41. ActiveRecord p = new Person p = new Person(:first => "May", :last => "Fong") p.save p.save! Person.create(:first => "May", :last => "Fong") Person.create!(:first => "May", :last => "Fong")
  • 42. Safe from SQL injection class 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