SlideShare a Scribd company logo
Ruby on Rails
A Complete Introduction
Good Morning
                                Welcome to Carsonified

                .
         a ve..
  is is D
Th


                    Hi there!
Who am I?
                         Adam Cooke


       I work at...               which is part of




                 ...
I have developed

                                                     and lots of other stuf
                                                                            f
... and you are?
So, the plan...
Introduction
The Rails Basics
Building a Blogging Engine
More Advancement
Testing
When things go wrong!
Deployments
Finishing up
re   ...
                         a re he
                   you

1   Introduction            What is Rails?
                            The MVC Pattern
                            Ruby Overview
                            RubyGems
                            Installing Rails
                            Components of Rails
What is Rails?
David Heinemeier Hansson
                  aka DHH
          & the res
                    t of the R
                               ails Core
                                         Team
[title]
 [sub title]
Who’s using Rails?
Ruby on Rails Presentation
The MVC Pattern
   Model-view-controller
Controller




Model                View
Rails routing happens here
                      Controller




      Model                                       View


Database   Resource
                                   Return to the browser
Ruby
Simple
Easy to write

          Elegant
Everything is an object
 Module                String
            Hash

    Array                 Proc
              Fixnum
 Symbol                 Numeric
class Numeric
    def plus(x)
        self.+(x)
    end
end

y = 5.plus 10 #=> 15
5.times { puts “Hello!” }
Ruby Objects
Variables                                  For example

Any plain, lowercase word                  a, my_variable and banana10


       out...
Try it


>> blah
NameError: undefined local variable or method `blah'

>>    string = “Hello World!”
=>    “Hello World!”
>>    string
=>    “Hello World!”
Numbers                           For example

Integers - positive or negative   1, 41231 and
                                  -68835

       out...
Try it

>>    5 + 10
=>    15
>>    10 * 10
=>    100
>>    3.1 + 1.55
=>    4.65
Strings                         For example

Anything surrounded by quotes   “Dave”, “123”and “My name
                                is...”

       out...
Try it

>>    my_quote = “My name is Dave!”
=>    “My name is Dave!”
>>    my_quote
=>    “My name is Dave!”
Symbols                               For example

Start with a colon, look like words   :a, :first_name and :abc123


       out...
Try it

>>    my_symbol = :complete
=>    :complete
>>    my_symbol
=>    :complete
Constants                                      For example

Like variables, with a capital                Hash, Monkey and Dave_The_Frog


       out...
Try it

>> MyMonkey = “James”
                                               Yo
                                                 us
=> “James”                                              hou
                                                              ldn
                                                                    ’t
>> MyMonkey = “Michael”                                                  ch
                                                                           an
(irb):1: warning: already initialized constant MyMonkey                         ge
                                                                                   it,a
=> “Michael”                                                                            ft
                                                                                          er
                                                                                             it   ’s
                                                                                                       be
                                                                                                         en
                                                                                                              se
                                                                                                                t
Methods            For example

The verbs!         say_hello and close


       out...
Try it

>> def say_hello
>> puts “Hello!”
>> end
>> say_hello
Hello!
=> nil
Method Args               For example

Passing data to methods   say_hello(name)


       out...
Try it

>> def say_hello(name, age)
>> puts “Hello #{name}!”
>> puts “You are #{age}!”
>> end
>> say_hello(‘Keir’, 45)
Hello Keir!
You are 45!
=> nil
Method Args               For example

Passing data to methods   say_hello(name)


       out...
Try it

>> def say_hello(name, age)
>> puts “Hello #{name}!”
>> puts “You are #{age}!”
>> end
>> say_hello(‘Keir’, 45)
Hello Keir!
You are 30!
=> nil
Arrays                                 For example

A list surrounded by square brackets   [1,2,3] and [‘A’,‘B’,‘C’]


       out...
Try it

>>    a = [1,2,3,4,5]
=>    [1,2,3,4,5]
>>    a
=>    [1,2,3,4,5]
>>    a[1]
=>    2
>>    a[1, 3]
=>    [2,3,4]
Hashes                              For example

A list surrounded by curly braces   {1=>2, 3=>4} and
                                    {:a => ‘Ant’,
                                     :b => ‘Badger’}
       out...
Try it

>>    h = {:a => ‘Good’, :b => ‘Bad’}
=>    {:a => ‘Good’, :b => ‘Bad’}
>>    h(:a)
=>    ‘Good’
>>    h.keys
=>    [:a, :b]
>>    h.values
=>    [‘Good’, ‘Bad’]
The Big One...
Classes
Anatomy of a class
class Person
    attr_accessor :first_name, :last_name
end

             p = Person.new
             p.first_name = ‘Dave’
             p.last_name = ‘Jones’
             p.first_name #=> “Dave”
class Person
   attr_accessor :first_name, :last_name

      def initialize(first, last)
          self.first_name = first
          self.last_name = last
      end

      def full_name
         [self.first_name, self.last_name].join(“ ”)
      end
end
                p = Person.new(‘Dave’, ‘Jones’)
                p.first_name #=> “Dave”
                p.last_name   #=> “Jones”
                p.full_name   #=> “Dave Jones”
Ruby Gems
Your Ruby Package Manager
user@dev01:~#                          gem list
*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (2.1.0, 2.0.2, 1.3.6, 1.3.3)
actionpack (2.1.0, 2.0.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.1.0, 2.0.2, 1.15.6, 1.15.3)
activeresource (2.1.0, 2.0.2)
activesupport (2.1.0, 2.0.2, 1.4.4, 1.4.2)
acts_as_ferret (0.4.1)
aws-s3 (0.4.0)
builder (2.1.2)
capistrano (2.3.0, 1.4.0)
cgi_multipart_eof_fix (2.5.0, 2.2)
cheat (1.2.1)
chronic (0.2.3)
codebase-gem (1.0.3)
daemons (1.0.10, 1.0.9, 1.0.7)
dnssd (0.6.0)
erubis (2.5.0)
gem install rails
gem remove rails
gem update rails
Useful Gems
                   The Rails Gems

rails              actionmailer
                    actionpack
mongrel_cluster    activerecord
capistrano        activeresource
mysql             activesupport
                       rails
                       rake
Components of Rails
        Action Pack
      Active Support
       Active Record
       Action Mailer
      Active Resource
Action Pack
All the view & controller logic
Active Support
Collection of utility classes and library extensions
Active Record
 The object relationship mapper
Action Mailer
   E-Mail Delivery
1   Introduction   What is Rails?
                   The MVC Pattern
                   Ruby Overview
                   RubyGems
                   Installing Rails
                   Components of Rails          ...
                                        are here
                                  you
re   ...
                          a re he
                    you

2   The Rails Basics Development Tools & Environment
                     Generating an Application
                     The Directory Structure
                     Starting up the app
                     “RESTful Rails”
                     Routing & URLs
Active Resource
  Connect with REST web services
Editors & IDEs
Database Browsers
Generating an App.
    rails my_app_name

rails my_app_name -d mysql
app      Contains the majority of your application specific code
config   Application config - routing map, database config etc...
db       Database schema, SQLite database files & migrations
doc      Generated HTML API documentation for the application or Rails
lib      Application-specific libraries - anything which doesn’t belong in app/
log      Log files and web server PID files
public   Your webserver document root - contains images, JS, CSS etc...
script   Rails helper scripts for automation and generation
test     Unit & functional tests along with any fixtures
tmp      Application specific temporary files
vendor   External libraries used in the application - gems, plugins etc...
app      controllers     Controllers named as posts_controller.rb
config   helpers         View helpers named as posts_helper.rb
db       models          Models named as post.rb
doc      views           Controller template files named as
                         posts/index.html.erb for the
lib                      PostsController#index action
log      views/layouts   Layout template files in the format of
                         application.html.erb for an
public                   application wide layout or posts.html.erb
script                   for controller specific layouts.
test
tmp
vendor
Starting the App
   Running a Local Webserver

   script/server
“RESTful Rails”
 Representational State Transfer
HTTP Methods
GET     POST     PUT      DELETE


READ    CREATE   UPDATE   DESTROY
Resource: Customer

/customers             GET   index   POST   create




/customers/1234        GET   show    PUT    update   DELETE   destroy



/customers/new         GET   new




/customers/1234/edit   GET   edit
Routing & URLs
    config/routes.rb
domain.com/my-page
map.connect “my-page”, :controller => “pages”, :action => “my”


domain.com/customers (as a resource)
map.resources :customers


domain.com (the root domain)
map.root :controller => “pages”, :action => “homepage”


domain.com/pages/about
map.connect “pages/:action”, :controller => “pages”


domain.com/pages/about/123
map.connect “:controller/:action/:id”
Named Routes
    rake routes
URL Helpers can use named routes (link_to, form for...)
<%=link_to ‘Homepage’, root_path%>


<%=link_to ‘Customer List’, customers_path%>


<%=link_to ‘View this Customer’, customer_path(1234)%>


<%=link_to ‘Edit this Customer’, edit_customer_path(1234)%>


<%form_for :customer, :url => customers_path do |f|...%>


                                           A POST request - so will call the ‘create’ action
2   The Rails Basics Development Tools & Environment
                     Generating an Application
                     The Directory Structure
                     Starting up the app
                     “RESTful Rails”
                     Routing & URLs
                                                 ...
                                         are here
                                   you
Ad

More Related Content

What's hot (20)

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Ranjith Siji
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
Laravel
LaravelLaravel
Laravel
tanveerkhan62
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
laravel.pptx
laravel.pptxlaravel.pptx
laravel.pptx
asif290119
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
Obinna Akunne
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
Piyush Aggarwal
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
Arvind Devaraj
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Dzmitry Naskou
 
Asp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkAsp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity Framework
Shravan A
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
Lilia Sfaxi
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
jQuery
jQueryjQuery
jQuery
Dileep Mishra
 
Node js
Node jsNode js
Node js
Fatih Şimşek
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
TheCreativedev Blog
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
SaziaRahman
 
Java script
Java scriptJava script
Java script
Shyam Khant
 

Similar to Ruby on Rails Presentation (20)

Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
Diego Lemos
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
Wes Oldenbeuving
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScript
Stalin Thangaraj
 
Fog City Ruby - Triple Equals Black Magic with speaker notes
Fog City Ruby - Triple Equals Black Magic with speaker notesFog City Ruby - Triple Equals Black Magic with speaker notes
Fog City Ruby - Triple Equals Black Magic with speaker notes
Brandon Weaver
 
Learning Ruby
Learning RubyLearning Ruby
Learning Ruby
David Francisco
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
Henry S
 
Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
Sarah Allen
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
ppparthpatel123
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Ryan Cross
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
Michael Koby
 
Story for a Ruby on Rails Single Engineer
Story for a Ruby on Rails Single EngineerStory for a Ruby on Rails Single Engineer
Story for a Ruby on Rails Single Engineer
TylerJohnson988371
 
Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)
Gautam Rege
 
Ruby
RubyRuby
Ruby
Vladimir Bystrov
 
Ruby — An introduction
Ruby — An introductionRuby — An introduction
Ruby — An introduction
Gonçalo Silva
 
Ruby 程式語言入門導覽
Ruby 程式語言入門導覽Ruby 程式語言入門導覽
Ruby 程式語言入門導覽
Wen-Tien Chang
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
Erin Dees
 
A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares DornellesA linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
Tchelinux
 
Ruby Programming Language
Ruby Programming LanguageRuby Programming Language
Ruby Programming Language
Duda Dornelles
 
Ruby
RubyRuby
Ruby
Kerry Buckley
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
Vysakh Sreenivasan
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
Diego Lemos
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScript
Stalin Thangaraj
 
Fog City Ruby - Triple Equals Black Magic with speaker notes
Fog City Ruby - Triple Equals Black Magic with speaker notesFog City Ruby - Triple Equals Black Magic with speaker notes
Fog City Ruby - Triple Equals Black Magic with speaker notes
Brandon Weaver
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
Henry S
 
Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
Sarah Allen
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
ppparthpatel123
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
Ryan Cross
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
Michael Koby
 
Story for a Ruby on Rails Single Engineer
Story for a Ruby on Rails Single EngineerStory for a Ruby on Rails Single Engineer
Story for a Ruby on Rails Single Engineer
TylerJohnson988371
 
Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)
Gautam Rege
 
Ruby — An introduction
Ruby — An introductionRuby — An introduction
Ruby — An introduction
Gonçalo Silva
 
Ruby 程式語言入門導覽
Ruby 程式語言入門導覽Ruby 程式語言入門導覽
Ruby 程式語言入門導覽
Wen-Tien Chang
 
Playfulness at Work
Playfulness at WorkPlayfulness at Work
Playfulness at Work
Erin Dees
 
A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares DornellesA linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
A linguagem de programação Ruby - Robson "Duda" Sejan Soares Dornelles
Tchelinux
 
Ruby Programming Language
Ruby Programming LanguageRuby Programming Language
Ruby Programming Language
Duda Dornelles
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
Vysakh Sreenivasan
 
Ad

Recently uploaded (20)

SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Ad

Ruby on Rails Presentation

  • 1. Ruby on Rails A Complete Introduction
  • 2. Good Morning Welcome to Carsonified . a ve.. is is D Th Hi there!
  • 3. Who am I? Adam Cooke I work at... which is part of ... I have developed and lots of other stuf f
  • 4. ... and you are?
  • 6. Introduction The Rails Basics Building a Blogging Engine More Advancement Testing When things go wrong! Deployments Finishing up
  • 7. re ... a re he you 1 Introduction What is Rails? The MVC Pattern Ruby Overview RubyGems Installing Rails Components of Rails
  • 9. David Heinemeier Hansson aka DHH & the res t of the R ails Core Team
  • 13. The MVC Pattern Model-view-controller
  • 15. Rails routing happens here Controller Model View Database Resource Return to the browser
  • 16. Ruby
  • 18. Everything is an object Module String Hash Array Proc Fixnum Symbol Numeric
  • 19. class Numeric def plus(x) self.+(x) end end y = 5.plus 10 #=> 15
  • 20. 5.times { puts “Hello!” }
  • 22. Variables For example Any plain, lowercase word a, my_variable and banana10 out... Try it >> blah NameError: undefined local variable or method `blah' >> string = “Hello World!” => “Hello World!” >> string => “Hello World!”
  • 23. Numbers For example Integers - positive or negative 1, 41231 and -68835 out... Try it >> 5 + 10 => 15 >> 10 * 10 => 100 >> 3.1 + 1.55 => 4.65
  • 24. Strings For example Anything surrounded by quotes “Dave”, “123”and “My name is...” out... Try it >> my_quote = “My name is Dave!” => “My name is Dave!” >> my_quote => “My name is Dave!”
  • 25. Symbols For example Start with a colon, look like words :a, :first_name and :abc123 out... Try it >> my_symbol = :complete => :complete >> my_symbol => :complete
  • 26. Constants For example Like variables, with a capital Hash, Monkey and Dave_The_Frog out... Try it >> MyMonkey = “James” Yo us => “James” hou ldn ’t >> MyMonkey = “Michael” ch an (irb):1: warning: already initialized constant MyMonkey ge it,a => “Michael” ft er it ’s be en se t
  • 27. Methods For example The verbs! say_hello and close out... Try it >> def say_hello >> puts “Hello!” >> end >> say_hello Hello! => nil
  • 28. Method Args For example Passing data to methods say_hello(name) out... Try it >> def say_hello(name, age) >> puts “Hello #{name}!” >> puts “You are #{age}!” >> end >> say_hello(‘Keir’, 45) Hello Keir! You are 45! => nil
  • 29. Method Args For example Passing data to methods say_hello(name) out... Try it >> def say_hello(name, age) >> puts “Hello #{name}!” >> puts “You are #{age}!” >> end >> say_hello(‘Keir’, 45) Hello Keir! You are 30! => nil
  • 30. Arrays For example A list surrounded by square brackets [1,2,3] and [‘A’,‘B’,‘C’] out... Try it >> a = [1,2,3,4,5] => [1,2,3,4,5] >> a => [1,2,3,4,5] >> a[1] => 2 >> a[1, 3] => [2,3,4]
  • 31. Hashes For example A list surrounded by curly braces {1=>2, 3=>4} and {:a => ‘Ant’, :b => ‘Badger’} out... Try it >> h = {:a => ‘Good’, :b => ‘Bad’} => {:a => ‘Good’, :b => ‘Bad’} >> h(:a) => ‘Good’ >> h.keys => [:a, :b] >> h.values => [‘Good’, ‘Bad’]
  • 33. Classes Anatomy of a class class Person attr_accessor :first_name, :last_name end p = Person.new p.first_name = ‘Dave’ p.last_name = ‘Jones’ p.first_name #=> “Dave”
  • 34. class Person attr_accessor :first_name, :last_name def initialize(first, last) self.first_name = first self.last_name = last end def full_name [self.first_name, self.last_name].join(“ ”) end end p = Person.new(‘Dave’, ‘Jones’) p.first_name #=> “Dave” p.last_name #=> “Jones” p.full_name #=> “Dave Jones”
  • 35. Ruby Gems Your Ruby Package Manager
  • 36. user@dev01:~# gem list *** LOCAL GEMS *** abstract (1.0.0) actionmailer (2.1.0, 2.0.2, 1.3.6, 1.3.3) actionpack (2.1.0, 2.0.2, 1.13.6, 1.13.3) actionwebservice (1.2.6, 1.2.3) activerecord (2.1.0, 2.0.2, 1.15.6, 1.15.3) activeresource (2.1.0, 2.0.2) activesupport (2.1.0, 2.0.2, 1.4.4, 1.4.2) acts_as_ferret (0.4.1) aws-s3 (0.4.0) builder (2.1.2) capistrano (2.3.0, 1.4.0) cgi_multipart_eof_fix (2.5.0, 2.2) cheat (1.2.1) chronic (0.2.3) codebase-gem (1.0.3) daemons (1.0.10, 1.0.9, 1.0.7) dnssd (0.6.0) erubis (2.5.0)
  • 37. gem install rails gem remove rails gem update rails
  • 38. Useful Gems The Rails Gems rails actionmailer actionpack mongrel_cluster activerecord capistrano activeresource mysql activesupport rails rake
  • 39. Components of Rails Action Pack Active Support Active Record Action Mailer Active Resource
  • 40. Action Pack All the view & controller logic
  • 41. Active Support Collection of utility classes and library extensions
  • 42. Active Record The object relationship mapper
  • 43. Action Mailer E-Mail Delivery
  • 44. 1 Introduction What is Rails? The MVC Pattern Ruby Overview RubyGems Installing Rails Components of Rails ... are here you
  • 45. re ... a re he you 2 The Rails Basics Development Tools & Environment Generating an Application The Directory Structure Starting up the app “RESTful Rails” Routing & URLs
  • 46. Active Resource Connect with REST web services
  • 49. Generating an App. rails my_app_name rails my_app_name -d mysql
  • 50. app Contains the majority of your application specific code config Application config - routing map, database config etc... db Database schema, SQLite database files & migrations doc Generated HTML API documentation for the application or Rails lib Application-specific libraries - anything which doesn’t belong in app/ log Log files and web server PID files public Your webserver document root - contains images, JS, CSS etc... script Rails helper scripts for automation and generation test Unit & functional tests along with any fixtures tmp Application specific temporary files vendor External libraries used in the application - gems, plugins etc...
  • 51. app controllers Controllers named as posts_controller.rb config helpers View helpers named as posts_helper.rb db models Models named as post.rb doc views Controller template files named as posts/index.html.erb for the lib PostsController#index action log views/layouts Layout template files in the format of application.html.erb for an public application wide layout or posts.html.erb script for controller specific layouts. test tmp vendor
  • 52. Starting the App Running a Local Webserver script/server
  • 54. HTTP Methods GET POST PUT DELETE READ CREATE UPDATE DESTROY
  • 55. Resource: Customer /customers GET index POST create /customers/1234 GET show PUT update DELETE destroy /customers/new GET new /customers/1234/edit GET edit
  • 56. Routing & URLs config/routes.rb
  • 57. domain.com/my-page map.connect “my-page”, :controller => “pages”, :action => “my” domain.com/customers (as a resource) map.resources :customers domain.com (the root domain) map.root :controller => “pages”, :action => “homepage” domain.com/pages/about map.connect “pages/:action”, :controller => “pages” domain.com/pages/about/123 map.connect “:controller/:action/:id”
  • 58. Named Routes rake routes
  • 59. URL Helpers can use named routes (link_to, form for...) <%=link_to ‘Homepage’, root_path%> <%=link_to ‘Customer List’, customers_path%> <%=link_to ‘View this Customer’, customer_path(1234)%> <%=link_to ‘Edit this Customer’, edit_customer_path(1234)%> <%form_for :customer, :url => customers_path do |f|...%> A POST request - so will call the ‘create’ action
  • 60. 2 The Rails Basics Development Tools & Environment Generating an Application The Directory Structure Starting up the app “RESTful Rails” Routing & URLs ... are here you