142
Présentation de Ruby on Rails Nicolas Cavigneaux Juillet 2007 1

Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Embed Size (px)

Citation preview

Page 1: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Présentation deRuby on Rails

Nicolas CavigneauxJuillet 2007

1

Page 2: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Qui suis-je ?

Nicolas Cavigneaux

Ingénieur d’étude et développement chez webpulser

Spécialisé en Ruby

Amoureux de Rails

2

Page 3: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby on Rails

3

Page 4: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby on Rails

• Un framework pour les applications Web

3

Page 5: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby on Rails

• Un framework pour les applications Web

• Écrit à l’aide de Ruby

3

Page 6: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby on Rails

• Un framework pour les applications Web

• Écrit à l’aide de Ruby

• Inventé par David Heinemeier Hansson

3

Page 7: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby on Rails

• Un framework pour les applications Web

• Écrit à l’aide de Ruby

• Inventé par David Heinemeier Hansson• Souple, élégant, dynamique, agile, productif,

complet, …

3

Page 8: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

4

Page 9: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

• À la base de Rails

4

Page 10: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

• À la base de Rails• Langage de script objet

4

Page 11: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

• À la base de Rails• Langage de script objet• Dynamique

4

Page 12: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

• À la base de Rails• Langage de script objet• Dynamique• Souple

4

Page 13: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

• À la base de Rails• Langage de script objet• Dynamique• Souple• Syntaxe élégante

4

Page 14: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Ruby !

• À la base de Rails• Langage de script objet• Dynamique• Souple• Syntaxe élégante• Inspiré de Smalltalk et Lisp

4

Page 15: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?

5

Page 16: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

5

Page 17: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

5

Page 18: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

5

Page 19: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

Définition d’une méthode

5

Page 20: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

Définition d’une méthode

5

Page 21: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

Définition d’une méthode

Appel de méthode avec deux paramètres

5

Page 22: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

Définition d’une méthode

Appel de méthode avec deux paramètres

5

Page 23: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

Définition d’une méthode

Appel de méthode avec deux paramètres

Appel à un itérateur

5

Page 24: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et la syntaxe ?class Voiture < Vehicule

def avancer(distance)deplacer(:avancer, distance)

distance.times do |i|klaxonner

endend

end

Définition d’une classe

Définition d’une méthode

Appel de méthode avec deux paramètres

Appel à un itérateur

5

Page 25: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

6

Page 26: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

• Vue d’ensemble

6

Page 27: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

• Vue d’ensemble• Le modèle MVC

6

Page 28: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

• Vue d’ensemble• Le modèle MVC

• Le Modèle : ActiveRecord

6

Page 29: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

• Vue d’ensemble• Le modèle MVC

• Le Modèle : ActiveRecord• La Vue : ActionView

6

Page 30: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

• Vue d’ensemble• Le modèle MVC

• Le Modèle : ActiveRecord• La Vue : ActionView• Le Contrôleur : ActionController

6

Page 31: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et Rails ?

• Vue d’ensemble• Le modèle MVC

• Le Modèle : ActiveRecord• La Vue : ActionView• Le Contrôleur : ActionController

• Développer avec Rails

6

Page 32: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Pourquoi Rails ?

7

Page 33: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Pourquoi Rails ?

• Pour prendre le meilleur de ce qui existe à l’heure actuelle !

7

Page 34: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Pourquoi Rails ?

• Pour prendre le meilleur de ce qui existe à l’heure actuelle !

• Interactivité, simplicité, souplesse

7

Page 35: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Pourquoi Rails ?

• Pour prendre le meilleur de ce qui existe à l’heure actuelle !

• Interactivité, simplicité, souplesse• Structuration, infrastructure puissante,

évolutivité

7

Page 36: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Pourquoi Rails ?

• Pour prendre le meilleur de ce qui existe à l’heure actuelle !

• Interactivité, simplicité, souplesse• Structuration, infrastructure puissante,

évolutivité• À mi-chemin des mondes PHP / J2EE

7

Page 37: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

8

Page 38: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

8

Page 39: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

8

Page 40: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

8

Page 41: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

8

Page 42: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

8

Page 43: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

8

Page 44: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

8

Page 45: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

id marque modele

1 Honda Civic

2 Nissan Micra

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

8

Page 46: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

id marque modele

1 Honda Civic

2 Nissan Micra

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

8

Page 47: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

id marque modele

1 Honda Civic

2 Nissan Micra

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

<html><body><h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

</body></html>

8

Page 48: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

id marque modele

1 Honda Civic

2 Nissan Micra

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

<html><body><h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

</body></html>

8

Page 49: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple

class Voiture < ActiveRecord::Baseend

id marque modele

1 Honda Civic

2 Nissan Micra

class GarageController < ApplicationController

def liste@voitures = Voiture.find(:all)

endend

<html><body><h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

</body></html>

Liste des voitures

Honda - CivicNissan - Micra

8

Page 50: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Définition d’un modèleActiveRecord

voituresLes tables correspondent

à des classes Ruby

Chaque colonne correspond à un attribut

de la classe

Chaque ligne représente un objet Ruby

ActiveRecord est un ORM (Object/Relational Mapper) :

Il assure le lien entre le monde objet de Ruby et le monde relationnel de la base de données.

9

Page 51: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Définition d’un modèleActiveRecord

id marque modele

1 Honda Civic

2 Nissan Micra

voituresLes tables correspondent

à des classes Ruby

Chaque colonne correspond à un attribut

de la classe

Chaque ligne représente un objet Ruby

ActiveRecord est un ORM (Object/Relational Mapper) :

Il assure le lien entre le monde objet de Ruby et le monde relationnel de la base de données.

9

Page 52: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’information

10

Page 53: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’information

• Rails découvre la structure de la base de données

10

Page 54: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’information

• Rails découvre la structure de la base de données

• Le développeur respecte quelques conventions

10

Page 55: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’information

• Rails découvre la structure de la base de données

• Le développeur respecte quelques conventions

• L’objectif est d’éviter la répétition et de simplifier la maintenance

10

Page 56: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’information

10

Page 57: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

10

Page 58: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

10

Page 59: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

INSERT INTO voitures ("marque", "modele") VALUES('Renault', 'Clio')

10

Page 60: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

v = Voiture.find(:first)puts v.marque

v.destroy

INSERT INTO voitures ("marque", "modele") VALUES('Renault', 'Clio')

10

Page 61: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

v = Voiture.find(:first)puts v.marque

v.destroy

INSERT INTO voitures ("marque", "modele") VALUES('Renault', 'Clio')

10

Page 62: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

v = Voiture.find(:first)puts v.marque

v.destroy

INSERT INTO voitures ("marque", "modele") VALUES('Renault', 'Clio')

SELECT * FROM voitures LIMIT 1

DELETE FROM voitures WHERE id = 1

10

Page 63: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Gestion de l’informationv = Voiture.newv.marque = “Renault”v.modele = “Clio”v.save

v = Voiture.find(:first)puts v.marque

v.destroy

INSERT INTO voitures ("marque", "modele") VALUES('Renault', 'Clio')

SELECT * FROM voitures LIMIT 1

DELETE FROM voitures WHERE id = 1

10

Page 64: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?

11

Page 65: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?class Voiture < ActiveRecord::Base

belongs_to :personneend

11

Page 66: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?class Voiture < ActiveRecord::Base

belongs_to :personneend

class Personne < ActiveRecord::Basehas_many :voitures

end

11

Page 67: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?class Voiture < ActiveRecord::Base

belongs_to :personneend

class Personne < ActiveRecord::Basehas_many :voitures

end

id marque modele personne_id

1 Honda Civic 2

2 Nissan Micra 1

11

Page 68: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?class Voiture < ActiveRecord::Base

belongs_to :personneend

class Personne < ActiveRecord::Basehas_many :voitures

end

id marque modele personne_id

1 Honda Civic 2

2 Nissan Micra 1

id nom prenom

1 Dupont Luc

2 Cavigneaux Nicolas

11

Page 69: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?class Voiture < ActiveRecord::Base

belongs_to :personneend

class Personne < ActiveRecord::Basehas_many :voitures

end

id marque modele personne_id

1 Honda Civic 2

2 Nissan Micra 1

id nom prenom

1 Dupont Luc

2 Cavigneaux Nicolas

11

Page 70: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Et les associations ?class Voiture < ActiveRecord::Base

belongs_to :personneend

class Personne < ActiveRecord::Basehas_many :voitures

end

id marque modele personne_id

1 Honda Civic 2

2 Nissan Micra 1

id nom prenom

1 Dupont Luc

2 Cavigneaux Nicolas

Conventions !

11

Page 71: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

UtilisationRails SQL

12

Page 72: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Utilisation

p = Personne.find_by_prenom(“Nicolas”)

p.voitures

Rails SQL

12

Page 73: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Utilisation

p = Personne.find_by_prenom(“Nicolas”)

p.voitures

SELECT * FROM personnes WHERE (personnes."prenom" = 'Nicolas')

SELECT * FROM voitures WHERE (voitures.personne_id = 2)

Rails SQL

12

Page 74: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Utilisation

p = Personne.find_by_prenom(“Nicolas”)

p.voitures

p = Personne.find_by_prenom(“Nicolas”, :include => :voitures)

SELECT * FROM personnes WHERE (personnes."prenom" = 'Nicolas')

SELECT * FROM voitures WHERE (voitures.personne_id = 2)

Rails SQL

12

Page 75: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Utilisation

p = Personne.find_by_prenom(“Nicolas”)

p.voitures

p = Personne.find_by_prenom(“Nicolas”, :include => :voitures)

SELECT * FROM personnes WHERE (personnes."prenom" = 'Nicolas')

SELECT * FROM voitures WHERE (voitures.personne_id = 2)

SELECT personnes.id, personnes.nom, personnes.prenom, voitures.id, voitures.marque, voitures.modele, voitures.personne_id FROM personnes LEFT OUTER JOIN voitures ON voitures.personne_id = personnes.id WHERE (personne.prenom = 'Nicolas')

Rails SQL

12

Page 76: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Mais j’ai des contraintes !

13

Page 77: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Mais j’ai des contraintes !

• ma base existe déjà• mes tables sont préfixées• mes index sont spécifiques• …

13

Page 78: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Mais j’ai des contraintes !

• ma base existe déjà• mes tables sont préfixées• mes index sont spécifiques• …

Convention ne veut pas dire obligation !

Vous pouvez préciser un comportement spécifique table par table et continuer à construire vos requêtes à la main.

13

Page 79: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les contrôleursActionController

14

Page 80: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les contrôleursActionController

http://localhost/garage/voir/2

14

Page 81: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les contrôleursActionController

http://localhost/garage/voir/2

class GarageController < ApplicationControllerdef voir

@voiture = Voiture.find(params[:id])end

end

14

Page 82: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les contrôleursActionController

http://localhost/garage/voir/2

class GarageController < ApplicationControllerdef voir

@voiture = Voiture.find(params[:id])end

end

Finalement , la vue adéquate sera rendue

14

Page 83: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

15

Page 84: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

• Logique de l’application

15

Page 85: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

• Logique de l’application• préparer les données à afficher

15

Page 86: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

• Logique de l’application• préparer les données à afficher• récupérer les informations d’un formulaire

15

Page 87: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

• Logique de l’application• préparer les données à afficher• récupérer les informations d’un formulaire• faire des vérifications (identification, …)

15

Page 88: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

• Logique de l’application• préparer les données à afficher• récupérer les informations d’un formulaire• faire des vérifications (identification, …)• gérer les redirections

15

Page 89: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Que mettre dans le contrôleur ?

• Logique de l’application• préparer les données à afficher• récupérer les informations d’un formulaire• faire des vérifications (identification, …)• gérer les redirections• récupérer des données externes

15

Page 90: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles

16

Page 91: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

16

Page 92: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter

16

Page 93: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter

16

Page 94: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter• around_filter

16

Page 95: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter• around_filter

• Le cache

16

Page 96: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter• around_filter

• Le cache• cache de page

16

Page 97: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter• around_filter

• Le cache• cache de page• cache d’action

16

Page 98: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter• around_filter

• Le cache• cache de page• cache d’action• cache de fragment

16

Page 99: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les outils disponibles• Les filtres

• before_filter• after_filter• around_filter

• Le cache• cache de page• cache d’action• cache de fragment

• Cookies et Sessions

16

Page 100: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exempleclass GarageController < ApplicationController

before_filter :logged_in?, :only => :nouveauafter_filter :compresscaches_action :liste

def nouveauif request.get?

@voiture = Voiture.newelse

@voiture = Voiture.create(params[:voiture])redirect_to :action => :liste

endend

def liste@voitures = Voiture.find(:all)

endend

17

Page 101: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les vuesActionView

18

Page 102: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les vuesActionView

• Gabarits HTML avec un peu de code Ruby

18

Page 103: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les vuesActionView

• Gabarits HTML avec un peu de code Ruby• Accès aux variables d’instances générées par

le contrôleur

18

Page 104: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Les vuesActionView

• Gabarits HTML avec un peu de code Ruby• Accès aux variables d’instances générées par

le contrôleur• De nombreux “helpers” pour simplifier

l’écriture des balises, formulaires, appels AJAX, …

18

Page 105: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

19

Page 106: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to

19

Page 107: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to• link_to_remote

19

Page 108: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to• link_to_remote• form_tag

19

Page 109: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to• link_to_remote• form_tag• text_field

19

Page 110: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to• link_to_remote• form_tag• text_field• date_select

19

Page 111: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to• link_to_remote• form_tag• text_field• date_select• …

19

Page 112: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Un exemple<html><body>

<h1>Liste des voitures</h1><% @voitures.each do |v| %>

<%= v.marque %> - <%= v.modele %><br/><% end %>

<%= link_to(‘Nouvelle voiture’, :action => :nouveau) %></body></html>

• link_to• link_to_remote• form_tag• text_field• date_select• …

Quelques helpers:

19

Page 113: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

20

Page 114: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application

20

Page 115: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code

20

Page 116: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

20

Page 117: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques

20

Page 118: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires

20

Page 119: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage

20

Page 120: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

20

Page 121: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

• Facilite le développement

20

Page 122: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

• Facilite le développement• rapide

20

Page 123: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

• Facilite le développement• rapide• interactif

20

Page 124: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

• Facilite le développement• rapide• interactif• échaffaudage

20

Page 125: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

• Facilite le développement• rapide• interactif• échaffaudage• générateur de code

20

Page 126: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Développer avec RoR

• Structuration de l’application• dans le code• dans l’arborescence du projet

• Encouragement aux bonnes pratiques• tests unitaires• conventions de nommage• migration des schémas

• Facilite le développement• rapide• interactif• échaffaudage• générateur de code

Les petits plus :

20

Page 127: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références

21

Page 128: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

21

Page 129: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby

21

Page 130: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way

21

Page 131: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails

21

Page 132: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes

21

Page 133: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

21

Page 134: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :

21

Page 135: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :• http://www.ruby-lang.org

21

Page 136: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :• http://www.ruby-lang.org• http://www.rubyonrails.org

21

Page 137: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :• http://www.ruby-lang.org• http://www.rubyonrails.org• http://www.rubyforge.org

21

Page 138: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :• http://www.ruby-lang.org• http://www.rubyonrails.org• http://www.rubyforge.org• http://www.railsfrance.org

21

Page 139: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :• http://www.ruby-lang.org• http://www.rubyonrails.org• http://www.rubyforge.org• http://www.railsfrance.org• http://blog.webpulser.com

21

Page 140: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Références• Livres :

• Programming Ruby• The Ruby Way• Ruby For Rails• Rails Recipes• Agile Web Development with Rails

• Web :• http://www.ruby-lang.org• http://www.rubyonrails.org• http://www.rubyforge.org• http://www.railsfrance.org• http://blog.webpulser.com• http://www.bounga.org

21

Page 141: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Des questions ?

22

Page 142: Présentation de Ruby on Rails - 2007.rmll.info2007.rmll.info/IMG/pdf/RMLL_-_Introduction_RoR.pdf · Ruby on Rails • Un framework pour les applications Web • Écrit à l’aide

Réutilisation du contenuLes contenus originaux de cette présentation sont diffusés sous licence Creative Commons avec les options :

• Paternité (obligation de mentionner l'auteur) • Pas d'utilisation commerciale (sans accord explicite) • Pas de modifications (contenu d'opinion)

La licence complète est disponible à l'adresse :http://creativecommons.org/licenses/by-nc-nd/2.0/fr/

Toute autre utilisation nécessite un accord explicite et écrit de la part de l'auteur.

Contact : [email protected]

23