SlideShare uma empresa Scribd logo
1 de 57
Introducción  a  Ruby On Rails Ing. Pablo Marrero
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introducción Ing. Pablo Marrero ,[object Object],[object Object],[object Object],Java Hibernate TopLink JPA EJB Spring Struts JSF Ruby on Rails
Introducción Ing. Pablo Marrero ,[object Object],[object Object],[object Object],Java Hibernate TopLink JPA EJB Spring Struts JSF Ruby on Rails Active Record Action Pack Action View Action Controller
Introducción Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Modelo Vista Controlador Browser BD
Introducción Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Ruby Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Ruby Ing. Pablo Marrero ,[object Object],[object Object],[object Object]
Pilares de RoR Ruby Ing. Pablo Marrero ,[object Object],[object Object],[object Object]
Pilares de RoR Ruby Ing. Pablo Marrero ,[object Object],variable_local @variable_de_instancia @@variable_de_clase $variable_global Clase CONSTANTE :simbolo metodo_de_instancia self.metodo_de_clase modifico_el_objeto! devuelvo_booleano?
Pilares de RoR Ruby Ing. Pablo Marrero Las estructuras  devuelven  el valor de la ultima expresión evaluada: @user = if params[:id] User.find(params[:id]) else User.new end
Pilares de RoR Ruby Ing. Pablo Marrero @post = Post.find(params[:id]) if @post @post.destroy end Mejor: if @post = Post.find(params[:id]) @post.destroy end
Pilares de RoR Ruby Ing. Pablo Marrero Asignaciones condicionales @title = "Tıtulo generico" unless defined?(@title) @title ||= "Tıtulo generico“ @heading = if defined?(@subsection) @subsection.title else @section.title end @heading = ( @subsection || @section ).title
Pilares de RoR Ruby Ing. Pablo Marrero Arrays @arr = [ 1, 2, 3, 4, 5 ] Iterando: @arr.each do |item| puts item end Que es el for de toda la vida: for item in @arr puts item end
Pilares de RoR Ruby Ing. Pablo Marrero Utilidades Varias para Arrays .uniq [1,1,2,3,3].uniq >> [1,2,3] .flatten [[1,1],2,[3,3]].flatten >> [1,1,2,3,3] .compact [1,nil,2,nil,3].compact >> [1,2,3] .reverse [1,1,2,3,3].reverse >> [3,3,2,1,1] .sort [1,3,2,1,3].sort >> [1,1,2,3,3] .find [1,2,3].find {|n| n % 3 == 0 } >> 3 [1,2,3].find {|n| n % 5 == 0 } >> nil .find_all [1,3,5,6].find_all {|n| n % 3 == 0 } >> [3,6] [1,2,3].find_all {|n| n % 5 == 0 } >> []
Pilares de RoR Ruby Ing. Pablo Marrero Que pasa con las clases? class Persona def nombre @nombre end def nombre=(nombre) @nombre = nombre end end No mas getter y setter!! class Persona attr_accesor :nombre, :apellido attr_reader :id attr_writer :notas end
Pilares de RoR Ruby Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],Yukihiro Matsumoto Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more efectively. By doing this, the machine will something something something."They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves. ,[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Convención sobre Configuración Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Convención sobre Configuración Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Dont Repeat Yourself Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Dont Repeat Yourself Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Active Record Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pilares de RoR Migrations Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Codificar! Instalación de Ruby y RoR Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Codificar! Instalación de Ruby y RoR Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object]
A Codificar! Instalación de Ruby y RoR Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Codificar! Herramientas de Desarrollo Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Codificar! Mini Proyecto Ing. Pablo Marrero ,[object Object]
Recursos Web Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Libros Ing. Pablo Marrero ,[object Object],[object Object]
¿ Preguntas ? Ing. Pablo Marrero
Referencias Ing. Pablo Marrero ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Muchas Gracias! Ing. Pablo Marrero ,[object Object],[object Object]

Mais conteúdo relacionado

Semelhante a Introducción a RubyOnRails

Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012
Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012
Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012
Alfredo Chavez
 
Ruby On Rails Jun2009
Ruby On Rails Jun2009Ruby On Rails Jun2009
Ruby On Rails Jun2009
Sergio Alonso
 
Introduccion A Php
Introduccion A PhpIntroduccion A Php
Introduccion A Php
uts
 
Introduccion A Php
Introduccion A PhpIntroduccion A Php
Introduccion A Php
uts
 
Introduccion A Php
Introduccion A PhpIntroduccion A Php
Introduccion A Php
uts
 
Programacion web
Programacion webProgramacion web
Programacion web
IACSA
 

Semelhante a Introducción a RubyOnRails (20)

Python django
Python djangoPython django
Python django
 
Meetup training Taller RoR
Meetup training Taller RoR Meetup training Taller RoR
Meetup training Taller RoR
 
Grails barcamp 2013
Grails barcamp 2013Grails barcamp 2013
Grails barcamp 2013
 
Presentacion Ruby on Rails en Universidad Autónoma 2009
Presentacion Ruby on Rails en Universidad Autónoma 2009Presentacion Ruby on Rails en Universidad Autónoma 2009
Presentacion Ruby on Rails en Universidad Autónoma 2009
 
Presentacion Ruby on Rails CTIC-Cusco2007
Presentacion Ruby on Rails CTIC-Cusco2007Presentacion Ruby on Rails CTIC-Cusco2007
Presentacion Ruby on Rails CTIC-Cusco2007
 
Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012
Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012
Retos en la Adopción del Refactoring - Junta General del MexALN 28/06/2012
 
Taller evento TestingUY 2016 - Automatización de Pruebas con Ruby
Taller evento TestingUY 2016 - Automatización de Pruebas con RubyTaller evento TestingUY 2016 - Automatización de Pruebas con Ruby
Taller evento TestingUY 2016 - Automatización de Pruebas con Ruby
 
Java jaucito
Java jaucitoJava jaucito
Java jaucito
 
Ruby on the Rails
Ruby on the RailsRuby on the Rails
Ruby on the Rails
 
Ruby On Rails Jun2009
Ruby On Rails Jun2009Ruby On Rails Jun2009
Ruby On Rails Jun2009
 
Introduccion A Php
Introduccion A PhpIntroduccion A Php
Introduccion A Php
 
Introduccion A Php
Introduccion A PhpIntroduccion A Php
Introduccion A Php
 
Introduccion A Php
Introduccion A PhpIntroduccion A Php
Introduccion A Php
 
Ruby on Rails - ETyC 2011
Ruby on Rails - ETyC 2011Ruby on Rails - ETyC 2011
Ruby on Rails - ETyC 2011
 
Desarrollo de Aplicaciones con Ruby on Rails y PostgreSQL
Desarrollo de Aplicaciones con Ruby on Rails y PostgreSQLDesarrollo de Aplicaciones con Ruby on Rails y PostgreSQL
Desarrollo de Aplicaciones con Ruby on Rails y PostgreSQL
 
Ruby es un lenguaje de programación interpretado
Ruby es un lenguaje de programación interpretadoRuby es un lenguaje de programación interpretado
Ruby es un lenguaje de programación interpretado
 
5 tips para programar en Ruby On Rails
5 tips para programar en Ruby On Rails 5 tips para programar en Ruby On Rails
5 tips para programar en Ruby On Rails
 
Programacion web
Programacion webProgramacion web
Programacion web
 
FULLSTACK JS DEV in 2017
FULLSTACK JS DEV in 2017FULLSTACK JS DEV in 2017
FULLSTACK JS DEV in 2017
 
Conceptos básicos y aplicaciones prácticas de programación para SEO
Conceptos básicos y aplicaciones prácticas de programación para SEOConceptos básicos y aplicaciones prácticas de programación para SEO
Conceptos básicos y aplicaciones prácticas de programación para SEO
 

Último

redes informaticas en una oficina administrativa
redes informaticas en una oficina administrativaredes informaticas en una oficina administrativa
redes informaticas en una oficina administrativa
nicho110
 

Último (10)

Avances tecnológicos del siglo XXI y ejemplos de estos
Avances tecnológicos del siglo XXI y ejemplos de estosAvances tecnológicos del siglo XXI y ejemplos de estos
Avances tecnológicos del siglo XXI y ejemplos de estos
 
Avances tecnológicos del siglo XXI 10-07 eyvana
Avances tecnológicos del siglo XXI 10-07 eyvanaAvances tecnológicos del siglo XXI 10-07 eyvana
Avances tecnológicos del siglo XXI 10-07 eyvana
 
Buenos_Aires_Meetup_Redis_20240430_.pptx
Buenos_Aires_Meetup_Redis_20240430_.pptxBuenos_Aires_Meetup_Redis_20240430_.pptx
Buenos_Aires_Meetup_Redis_20240430_.pptx
 
Innovaciones tecnologicas en el siglo 21
Innovaciones tecnologicas en el siglo 21Innovaciones tecnologicas en el siglo 21
Innovaciones tecnologicas en el siglo 21
 
redes informaticas en una oficina administrativa
redes informaticas en una oficina administrativaredes informaticas en una oficina administrativa
redes informaticas en una oficina administrativa
 
Guia Basica para bachillerato de Circuitos Basicos
Guia Basica para bachillerato de Circuitos BasicosGuia Basica para bachillerato de Circuitos Basicos
Guia Basica para bachillerato de Circuitos Basicos
 
Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...
Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...
Resistencia extrema al cobre por un consorcio bacteriano conformado por Sulfo...
 
EVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptx
EVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptxEVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptx
EVOLUCION DE LA TECNOLOGIA Y SUS ASPECTOSpptx
 
investigación de los Avances tecnológicos del siglo XXI
investigación de los Avances tecnológicos del siglo XXIinvestigación de los Avances tecnológicos del siglo XXI
investigación de los Avances tecnológicos del siglo XXI
 
How to use Redis with MuleSoft. A quick start presentation.
How to use Redis with MuleSoft. A quick start presentation.How to use Redis with MuleSoft. A quick start presentation.
How to use Redis with MuleSoft. A quick start presentation.
 

Introducción a RubyOnRails

  • 1. Introducción a Ruby On Rails Ing. Pablo Marrero
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. Pilares de RoR Ruby Ing. Pablo Marrero Las estructuras devuelven el valor de la ultima expresión evaluada: @user = if params[:id] User.find(params[:id]) else User.new end
  • 13. Pilares de RoR Ruby Ing. Pablo Marrero @post = Post.find(params[:id]) if @post @post.destroy end Mejor: if @post = Post.find(params[:id]) @post.destroy end
  • 14. Pilares de RoR Ruby Ing. Pablo Marrero Asignaciones condicionales @title = "Tıtulo generico" unless defined?(@title) @title ||= "Tıtulo generico“ @heading = if defined?(@subsection) @subsection.title else @section.title end @heading = ( @subsection || @section ).title
  • 15. Pilares de RoR Ruby Ing. Pablo Marrero Arrays @arr = [ 1, 2, 3, 4, 5 ] Iterando: @arr.each do |item| puts item end Que es el for de toda la vida: for item in @arr puts item end
  • 16. Pilares de RoR Ruby Ing. Pablo Marrero Utilidades Varias para Arrays .uniq [1,1,2,3,3].uniq >> [1,2,3] .flatten [[1,1],2,[3,3]].flatten >> [1,1,2,3,3] .compact [1,nil,2,nil,3].compact >> [1,2,3] .reverse [1,1,2,3,3].reverse >> [3,3,2,1,1] .sort [1,3,2,1,3].sort >> [1,1,2,3,3] .find [1,2,3].find {|n| n % 3 == 0 } >> 3 [1,2,3].find {|n| n % 5 == 0 } >> nil .find_all [1,3,5,6].find_all {|n| n % 3 == 0 } >> [3,6] [1,2,3].find_all {|n| n % 5 == 0 } >> []
  • 17. Pilares de RoR Ruby Ing. Pablo Marrero Que pasa con las clases? class Persona def nombre @nombre end def nombre=(nombre) @nombre = nombre end end No mas getter y setter!! class Persona attr_accesor :nombre, :apellido attr_reader :id attr_writer :notas end
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55. ¿ Preguntas ? Ing. Pablo Marrero
  • 56.
  • 57.