SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Kürzlich hochgeladen (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
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
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

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