SlideShare a Scribd company logo
1 of 99
Rails for the PHP Dev
(You know youʼre curious...)




November 7, 2009
BIGLAMPCAMP
blog.adsdevshop.com

rdempsey

atlanticdominionsolutions
My Pet Peeves
My Pet Peeves

People that drive slow (in general)
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
People that read books while they drive
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
People that read books while they drive
People that canʼt make up their mind
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
People that read books while they drive
People that canʼt make up their mind
People that post anonymous comments (weak)
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
People that read books while they drive
People that canʼt make up their mind
People that post anonymous comments (weak)
Trolls, Internet or otherwise
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
People that read books while they drive
People that canʼt make up their mind
People that post anonymous comments (weak)
Trolls, Internet or otherwise
People that fuck with my sprint
My Pet Peeves

People that drive slow (in general)
People that donʼt use their turn signal
People that read books while they drive
People that canʼt make up their mind
People that post anonymous comments (weak)
Trolls, Internet or otherwise
People that fuck with my sprint
Asshole bosses who wonʼt understand their people
Ruby - History
Ruby - History

Released in 1995 by Yukihiro “Matz” Matsumoto
Ruby - History

Released in 1995 by Yukihiro “Matz” Matsumoto
Blends Perl, Smalltalk, Eiffel, Ada, and Lisp
Ruby - History

Released in 1995 by Yukihiro “Matz” Matsumoto
Blends Perl, Smalltalk, Eiffel, Ada, and Lisp
Natural language syntax
Ruby - History

Released in 1995 by Yukihiro “Matz” Matsumoto
Blends Perl, Smalltalk, Eiffel, Ada, and Lisp
Natural language syntax
Mass acceptance in 2006
Ruby - Objects
Ruby - Objects

Everything is an object
Ruby - Objects

Everything is an object
Everything can be given its own properties (instance
variables) and actions (methods)
Ruby - Objects

Everything is an object
Everything can be given its own properties (instance
variables) and actions (methods)
All types have methods and instance variables
Ruby - Objects

Everything is an object
Everything can be given its own properties (instance
variables) and actions (methods)
All types have methods and instance variables
The same rules apply everywhere
Ruby - Objects

Everything is an object
Everything can be given its own properties (instance
variables) and actions (methods)
All types have methods and instance variables
The same rules apply everywhere
Remove, redefine, and extend at will
Ruby on Rails - History
Ruby on Rails - History

Released in 2005 by David Heinemeier Hansson
Ruby on Rails - History

Released in 2005 by David Heinemeier Hansson
Full-stack framework for developing database-backed web
apps
Ruby on Rails - History

Released in 2005 by David Heinemeier Hansson
Full-stack framework for developing database-backed web
apps
MVC
Ruby on Rails - History

Released in 2005 by David Heinemeier Hansson
Full-stack framework for developing database-backed web
apps
MVC
Builds on the power of Ruby
Ruby on Rails - History

Released in 2005 by David Heinemeier Hansson
Full-stack framework for developing database-backed web
apps
MVC
Builds on the power of Ruby
Convention over configuration
Ruby on Rails - Common Uses

Dynamic web sites
Data warehousing and data mining
Statistics reporting
Management applications
Collaborative apps
Community sites
E-commerce
...
PHP MVC Frameworks

Cake PHP
SolarPHP
Symfony
(others)
Arrays - PHP
Arrays - PHP


in_array($needle, $haystack);
Arrays - PHP


in_array($needle, $haystack);

array_push($haystack, $needle);
Arrays - Ruby


                1
                2
                3
                4
Variable Assignment - PHP
Variable Assignment - PHP


$a = array();
Variable Assignment - PHP


$a = array();

$b = $a;
Variable Assignment - PHP


$a = array();

$b = $a;

$a[ʻfooʼ] = ʻbarʼ;
Variable Assignment - PHP


$a = array();

$b = $a;

$a[ʻfooʼ] = ʻbarʼ;

var_export($a); =>   array(ʻfooʼ => ʻbarʼ)
Variable Assignment - PHP


$a = array();

$b = $a;

$a[ʻfooʼ] = ʻbarʼ;

var_export($a); =>   array(ʻfooʼ => ʻbarʼ)

var_export($b); =>   array()
Variable Assignment - Ruby
Variable Assignment - Ruby


a = {}            => {}
Variable Assignment - Ruby


a = {}            => {}

b=a               => {}
Variable Assignment - Ruby


a = {}               => {}

b=a                  => {}

a[ʻfooʼ] = ʻbarʻ   => “bar”
Variable Assignment - Ruby


a = {}               => {}

b=a                  => {}

a[ʻfooʼ] = ʻbarʻ   => “bar”

a                    => {“foo” => “bar”}
Variable Assignment - Ruby


a = {}               => {}

b=a                  => {}

a[ʻfooʼ] = ʻbarʻ   => “bar”

a                    => {“foo” => “bar”}

b                    => {“foo” => “bar”}
Variable Assignment (2) - Ruby
Variable Assignment (2) - Ruby


a = ʻfooʻ        => “foo”
Variable Assignment (2) - Ruby


a = ʻfooʻ        => “foo”

b=a                => “foo”
Variable Assignment (2) - Ruby


a = ʻfooʻ        => “foo”

b=a                => “foo”

a.reverse!        => “oof”
Variable Assignment (2) - Ruby


a = ʻfooʻ        => “foo”

b=a                => “foo”

a.reverse!        => “oof”

b.reverse!        => “foo”
Variable Assignment (2) - Ruby


a = ʻfooʻ        => “foo”

b=a                => “foo”

a.reverse!        => “oof”

b.reverse!        => “foo”

a.equal? b         => true
http://www.flickr.com/photos/floridapfe/
Methods - PHP


class Monkey

    public function toss($fruit) {

        // toss a piece of fruit at someone

    }

}
Methods - Ruby


class Monkey

 def toss(fruit)

  # toss some fruit at someone

 end

end
Methods (2) - PHP


class Monkey

    public function toss($fruit, $feces = true) {

        // toss a piece of fruit at someone

    }

}
Methods (2) - Ruby


class Monkey

 def toss(fruit, feces = true)

  # toss some fruit at someone

 end

end
Passing Named Params - PHP


class Building {

    public function __construct($height = 10, $width = 10,

                                    $depth = 10)

    {

        // check and store params

    }

}
Passing Named Params (2) - PHP


$b = new Building(10,20,30);
Passing Named Params (3) - PHP


$b = new Building(array(ʻheightʼ => 10,

                         ʻwidthʼ => 20,

                         ʻdepthʼ => 50));
Passing Named Params - Ruby


$b = Building.new(:height => 10,

                  :width => 20,

                  :depth => 50)
Example PHP Function


for ($bananas = 50, $bananas > 0; $bananas --) {

    echo “The monkey has thrown $bananas bananasn”;

}
Example Ruby Block


50.downto(1) { | num | puts “#{num} bananas thrown” }
Example Ruby Block - Hidden Goodies


int.downto(limit) { |i| block } => int



Iterates block, passing decreasing values from int down to
and including limit.
Example Ruby Block


50.downto(1) { |num| puts “#{num} bananas thrown” }
Example Ruby Block - Result


50 bananas thrown

49 bananas thrown

48 bananas thrown

47 bananas thrown

46 bananas thrown

...

1 bananas thrown
Attributes - PHP


class Monkey {
  protected $species;
  public $name;
  public function __construct($species, $name) {
    $this -> species = $species;
    $this -> name = $name;
  }
}
Attributes - Ruby


class Monkey
 def initialize(species, name)
   @species = species
   @name = name
 end

 def species
   @species
 end
 ...
end
Attributes - Ruby


class Monkey
 attr_reader :species
 attr_accessor :name
 attr_writer :bananas_eaten

 def initialize(species, name)
 ...
end
Method Visibility - PHP


public function ...
protected function ...
protected function ...
private function ...
public function ...
Method Visibility - Ruby


class SomeClass

 def my_public_method
 end

 protected

   # Everything down here is protected
Method Visibility - Ruby


class Monkey

 private

   def format(value)
    value.capitalize
   end
Typing- Ruby
Typing- Ruby


foo = ʻbarʻ   =>   “bar”
Typing- Ruby


foo = ʻbarʻ   =>    “bar”

foo = 42       =>     42
Typing- Ruby


foo = ʻbarʻ   =>    “bar”

foo = 42       =>     42

foo + 2        =>      44
Typing- Ruby


foo = ʻbarʻ      =>    “bar”

foo = 42          =>     42

foo + 2           =>      44

foo + “2”.to_i    =>     44
Rails Application Structure


README
Rakefile
app
config
db
doc
lib
log
public
script
test
tmp
vendor
Rails Application Structure - app


app
 - controllers
 - helpers
 - models
 - views
Rails Application Structure - config


config
  - boot.rb
  - database.yml
  - environment.rb
  - environments
  - initializers
  - locales
  - routes.rb
Rails Application Structure - db


db
  - migrations
  - schema.rb
Rails Application Structure - The Rest


doc
lib
log
public
script
test
tmp
vendor
Start a Rails App


rails -d mysql railsforphpdevs
Start a Rails App


rails -d postgres railsforphpdevs
Start a Rails App


rails -d sqlite railsforphpdevs
Thanks!
Questions?

More Related Content

What's hot

MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
BUDNET
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
None
 

What's hot (20)

MIND sweeping introduction to PHP
MIND sweeping introduction to PHPMIND sweeping introduction to PHP
MIND sweeping introduction to PHP
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Coffee Script
Coffee ScriptCoffee Script
Coffee Script
 
Scalar data types
Scalar data typesScalar data types
Scalar data types
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
Synapseindia reviews on array php
Synapseindia reviews on array phpSynapseindia reviews on array php
Synapseindia reviews on array php
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Lists and arrays
Lists and arraysLists and arrays
Lists and arrays
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
Ruby from zero to hero
Ruby from zero to heroRuby from zero to hero
Ruby from zero to hero
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8Just-In-Time Compiler in PHP 8
Just-In-Time Compiler in PHP 8
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 

Viewers also liked

Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...
Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...
Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...
Theawaster485
 

Viewers also liked (7)

How To Turn Your Business Into A Media Powerhouse
How To Turn Your Business Into A Media PowerhouseHow To Turn Your Business Into A Media Powerhouse
How To Turn Your Business Into A Media Powerhouse
 
Agile: What You Want To Know
Agile: What You Want To KnowAgile: What You Want To Know
Agile: What You Want To Know
 
Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...
Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...
Avoiding Bullies Through Becoming Prisoners _ 60% Of Bullies Could Have Sente...
 
Get The **** Up And Market
Get The **** Up And MarketGet The **** Up And Market
Get The **** Up And Market
 
The Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with RubyThe Future is Now: Leveraging the Cloud with Ruby
The Future is Now: Leveraging the Cloud with Ruby
 
Content Marketing Strategy for 2013
Content Marketing Strategy for 2013Content Marketing Strategy for 2013
Content Marketing Strategy for 2013
 
A-Z Intro To Rails
A-Z Intro To RailsA-Z Intro To Rails
A-Z Intro To Rails
 

Similar to Rails for PHP Developers

OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
Lin Yo-An
 
Griffith uni
Griffith uniGriffith uni
Griffith uni
nigel99
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
clkao
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
sagaroceanic11
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
sagaroceanic11
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
Priceen
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
Wen-Tien Chang
 

Similar to Rails for PHP Developers (20)

Learning From Ruby (Yapc Asia)
Learning From Ruby (Yapc Asia)Learning From Ruby (Yapc Asia)
Learning From Ruby (Yapc Asia)
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
A bridge between php and ruby
A bridge between php and ruby A bridge between php and ruby
A bridge between php and ruby
 
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
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
 
Why everyone like ruby
Why everyone like rubyWhy everyone like ruby
Why everyone like ruby
 
Griffith uni
Griffith uniGriffith uni
Griffith uni
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
Flying under the radar
Flying under the radarFlying under the radar
Flying under the radar
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9Rubyforjavaprogrammers 1210167973516759-9
Rubyforjavaprogrammers 1210167973516759-9
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 

More from Robert Dempsey

More from Robert Dempsey (20)

Building A Production-Level Machine Learning Pipeline
Building A Production-Level Machine Learning PipelineBuilding A Production-Level Machine Learning Pipeline
Building A Production-Level Machine Learning Pipeline
 
Using PySpark to Process Boat Loads of Data
Using PySpark to Process Boat Loads of DataUsing PySpark to Process Boat Loads of Data
Using PySpark to Process Boat Loads of Data
 
Analyzing Semi-Structured Data At Volume In The Cloud
Analyzing Semi-Structured Data At Volume In The CloudAnalyzing Semi-Structured Data At Volume In The Cloud
Analyzing Semi-Structured Data At Volume In The Cloud
 
Practical Predictive Modeling in Python
Practical Predictive Modeling in PythonPractical Predictive Modeling in Python
Practical Predictive Modeling in Python
 
Creating Your First Predictive Model In Python
Creating Your First Predictive Model In PythonCreating Your First Predictive Model In Python
Creating Your First Predictive Model In Python
 
Growth Hacking 101
Growth Hacking 101Growth Hacking 101
Growth Hacking 101
 
Web Scraping With Python
Web Scraping With PythonWeb Scraping With Python
Web Scraping With Python
 
DC Python Intro Slides - Rob's Version
DC Python Intro Slides - Rob's VersionDC Python Intro Slides - Rob's Version
DC Python Intro Slides - Rob's Version
 
Creating Lead-Generating Social Media Campaigns
Creating Lead-Generating Social Media CampaignsCreating Lead-Generating Social Media Campaigns
Creating Lead-Generating Social Media Campaigns
 
Goal Writing Workshop
Goal Writing WorkshopGoal Writing Workshop
Goal Writing Workshop
 
Google AdWords Introduction
Google AdWords IntroductionGoogle AdWords Introduction
Google AdWords Introduction
 
20 Tips For Freelance Success
20 Tips For Freelance Success20 Tips For Freelance Success
20 Tips For Freelance Success
 
Agile Teams as Innovation Teams
Agile Teams as Innovation TeamsAgile Teams as Innovation Teams
Agile Teams as Innovation Teams
 
Introduction to kanban
Introduction to kanbanIntroduction to kanban
Introduction to kanban
 
Introduction To Inbound Marketing
Introduction To Inbound MarketingIntroduction To Inbound Marketing
Introduction To Inbound Marketing
 
Writing Agile Requirements
Writing  Agile  RequirementsWriting  Agile  Requirements
Writing Agile Requirements
 
Twitter For Business
Twitter For BusinessTwitter For Business
Twitter For Business
 
Introduction To Scrum For Managers
Introduction To Scrum For ManagersIntroduction To Scrum For Managers
Introduction To Scrum For Managers
 
Introduction to Agile for Managers
Introduction to Agile for ManagersIntroduction to Agile for Managers
Introduction to Agile for Managers
 
Sizing Your Stories
Sizing Your StoriesSizing Your Stories
Sizing Your Stories
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Rails for PHP Developers

Editor's Notes

  1. I’m the CEO and Founder of ADS, an Orlando based company that builds custom web and iPhone applications, and helps software companies implement Agile practices
  2. We have three apps that we develop
  3. Discount code for an additional free month
  4. We help connect freelancers and small business people with each other
  5. You can find us all over the Internet
  6. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  7. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  8. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  9. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  10. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  11. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  12. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  13. A little about me I cuss, a lot - if easily offended, Denis Leary: get a fucking helmet What about you? Who here is a PHP developer? Who here has messed around with Rails?
  14. This talk is based off the information presented in Rails for PHP Developers by Derek DeVries and Mike Naberezny I’ll be giving away a copy at the end of this talk
  15. I’m not here to convert you. This is not a this or that choice.
  16. As developers we have many tools to choose from. Rails is another tool we can use to build web apps.
  17. IMO, it’s easiest to learn Rails coming from PHP In fact, I was a php developer before moving to Rails The good news: there are a lot of similarities, which we’ll see To be a good Rails programmer, you need to know Ruby
  18. Highly flexible, which means that you can easily fuck it up
  19. Highly flexible, which means that you can easily fuck it up
  20. Highly flexible, which means that you can easily fuck it up
  21. Highly flexible, which means that you can easily fuck it up
  22. Highly flexible, which means that you can easily fuck it up
  23. Let’s dig into the specifics
  24. MVC like Rails
  25. So without further ado, let’s dig in.
  26. So without further ado, let’s dig in.
  27. in_array(value, array) array_push(array, value)
  28. in_array(value, array) array_push(array, value)
  29. Going back to the idea that everything in Ruby is an object, here’s an example.
  30. $a has the one value, and $b is empty All assignments here are by value
  31. $a has the one value, and $b is empty All assignments here are by value
  32. $a has the one value, and $b is empty All assignments here are by value
  33. $a has the one value, and $b is empty All assignments here are by value
  34. $a has the one value, and $b is empty All assignments here are by value
  35. In Ruby, both a and b contain a reference to the same Hash object In Ruby, the assignment always assigns by reference - big difference
  36. In Ruby, both a and b contain a reference to the same Hash object In Ruby, the assignment always assigns by reference - big difference
  37. In Ruby, both a and b contain a reference to the same Hash object In Ruby, the assignment always assigns by reference - big difference
  38. In Ruby, both a and b contain a reference to the same Hash object In Ruby, the assignment always assigns by reference - big difference
  39. In Ruby, both a and b contain a reference to the same Hash object In Ruby, the assignment always assigns by reference - big difference
  40. Methods on a and b are acting on the same object
  41. Methods on a and b are acting on the same object
  42. Methods on a and b are acting on the same object
  43. Methods on a and b are acting on the same object
  44. Methods on a and b are acting on the same object
  45. To help us look at methods, we turn to our friend the monkey
  46. Some are small, some look really cool. But all monkeys throw things.
  47. Pass in a single param
  48. Param (fruit) is optional
  49. Multiple params, set a default value You might get the fruit, but you have 100% chance of getting the feces
  50. Basic method declaration and optional params are pretty much the same
  51. Pass in our params and give them default values
  52. Use the class we created and create a building Need to ensure we have the right order for the params Hell if I’m going to remember that
  53. Using named params
  54. Using named params Here we use symbols, indicated by the “:”
  55. In Ruby we have blocks, which are like closures in javascript PHP 5.3 supports this
  56. Here we see a monkey throwing bananas by using a for loop As long as we have bananas to throw, the monkey throws them
  57. 50 is an integer object, and we’re calling the downto method
  58. 50 is an integer object, and we’re calling the downto method
  59. A block can take optional params, in this case the banana count, put between the goal posts The rest of the block is executable code
  60. The result What’s cool - every method in Ruby has the capability of being passed a block
  61. PHP uses data members to share data Visibility depends on the keywords used in the declaration
  62. The @species is similar to the PHP code No need for getter methods!
  63. attr_reader replaces our getter method attr_accessor replaces both the getter and setter attr_writer adds a setter method w/out the corresponding getter
  64. We have a mix of public, private, and protected based on the declaration
  65. Unless below the protected line, everything is public Protected methods cannot be publicly called
  66. Private methods in Ruby can be executed only within the context of the same object or derivative objects
  67. We can start with a string Retype on the fly Check that that’s happened
  68. We can start with a string Retype on the fly Check that that’s happened
  69. We can start with a string Retype on the fly Check that that’s happened
  70. We can start with a string Retype on the fly Check that that’s happened
  71. Quick overview of the Rails app structure and creating a Rails app
  72. README and Rakefile are files, the rest are directories
  73. app is where the bulk of the code lives
  74. All of the config files Supported databases: sqlite, postgres, mysql, oracle, MS SQL, more Environments: development, test, production Routes - all the REST goes here
  75. All migration files stored here (timestamped) Can roll forward or backward (and all data will be fubar) Schema.rb - current database schema
  76. Sqlite is default if you don’t pick the database you want Supports - MySQL, Postgres, Sqlite, MS SQL, Oracle, and many others