Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Initiation à Ruby on Rails
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Matthieu Segret
February 12, 2013
Programming
140
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Initiation à Ruby on Rails
Matthieu Segret
February 12, 2013
More Decks by Matthieu Segret
See All by Matthieu Segret
Initiation à Gosu
matthieusegret
0
66
Other Decks in Programming
See All in Programming
Flow は今どうなっているか
mizdra
PRO
0
700
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
540
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.7k
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
Oxlintはいいぞ(続)
yug1224
1
430
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
280
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
110
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.1k
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
230
Featured
See All Featured
Design in an AI World
tapps
1
290
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
480
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.5k
Prompt Engineering for Job Search
mfonobong
0
420
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
420
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
470
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
220
Facilitating Awesome Meetings
lara
57
7.1k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
450
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
670
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Transcript
Initiation à Ruby on Rails @humancoders
@matthieusegret
Matthieu Segret Formateur Ruby on Rails Cofondateur de Human Coders
Un langage : Ruby
• Langage interprété / orienté objet • Libre - Licence
Ruby et GPL • Version 1.9.3 (bientôt 2.0) • Apparu en 1995 Ruby
None
None
puts "Hello world" Ruby "ruby is cool".length # 12 -42.abs
# 42 "Nice Day Isn't It?".downcase.split # ["nice", "day", "isn't", "it?"]
class Book def initialize(name) @name = name end def name
@name end end Ruby book = Book.new("Programming Ruby") book.name # "Programming Ruby"
None
None
Un framework : Ruby on Rails
• Framework web écrit en Ruby • Libre - MIT
• Version 3.2 (bientôt 4.0) • Apparu en 2004 Ruby on Rails
Convention over Configuration
DRY (Don’t Repeat Yourself)
Projet : MyNotes
Projet : MyNotes $ rails new MyNotes • Créer un
nouveau projet $ cd MyNotes $ rails server • Démarrer le serveur
None
View Controller Model Routing
None
CRUD
Create Read Update Delete CRUD
Ressource : notes notes notes id integer title varchar content
text
$ rails generate scaffold note title content:text invoke active_record create
db/migrate/20130130171611_create_notes.rb create app/models/note.rb invoke test_unit create test/unit/note_test.rb create test/fixtures/notes.yml invoke resource_route route resources :notes invoke scaffold_controller create app/controllers/notes_controller.rb invoke erb create app/views/notes create app/views/notes/index.html.erb create app/views/notes/edit.html.erb create app/views/notes/show.html.erb create app/views/notes/new.html.erb create app/views/notes/_form.html.erb ... Génération du CRUD
Migration
migration 1 migration 2 migration 3 migration 4 Migration
devise_create_users acts_as_follower create_notes add_profile_to_user 20110720095338_ 20110718190746_ 20110715205012_ 20110605152153_ rake db:migrate
rake db:rollback current .rb Migration
Migration class CreateNotes < ActiveRecord::Migration def change create_table :notes do
|t| t.string :title t.text :content t.timestamps end end end db/migrate/20130130175117_create_notes.rb $ rake db:migrate
Base de données notes notes id integer title varchar content
text
None
Modèle
View Controller Model Routing
Modèle class Note < ActiveRecord::Base end app/models/note.rb
Modèle : création Note.create(content: "I created Ruby", title: "Matz")
Modèle : mise à jour note = Note.find(1) note.content =
"I love Ruby" note.save
Modèle : lecture Note.where(:title => "Matz").order("title ASC").limit(5)
Modèle : suppression Note.find(1).destroy
Vue
View Controller Model Routing
ERB <p> <b>Title:</b> <%= @note.title %> </p> <p> <b>Content:</b> <%=
@note.content %> </p> app/views/notes/show.html.erb
Formulaires <%= form_for(@note) do |f| %> <%= f.label :title %>
<%= f.text_field :title %> <%= f.label :content %> <%= f.text_area :content %> <%= f.submit %> <% end %>
Contrôleur
View Controller Model Routing
Contrôleur class NotesController < ApplicationController def show @note = Note.find(params[:id])
end end app/controllers/notes_controller.rb app/views/notes/show.html.erb Request GET /notes/1 <p> <b>Title:</b> <%= @note.title %> </p>
Déploiement
None
Les gems
Indexation Twitter NoSQL Paiement en ligne Géolocalisation Parsing Pagination Cache
Tâches de fonds Upload de fichiers Facebook Authentification Localisation OAuth A/B teste LDAP
La commautée Française
Montpellier Lyon Toulouse Nantes Rennes Lille Paris Sophia Antipolis Strasbourg
Marseille Compiegne Bordeaux
Aller plus loin
None
Programming Ruby 1.9 (3rd edition) Agile Web Development with Rails
(4th edition)
None
Formation
@humancoders Merci !