Your SlideShare is downloading. ×
  • Like
Pourquoi ruby et rails déchirent
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Pourquoi ruby et rails déchirent

  • 230 views
Published

Et bien il faut lire la présentation !

Et bien il faut lire la présentation !

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
230
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. POURQUOI RUBY ET RAILS DÉCHIRENT ! Par Nicolas Ledez
  • 2. RUBY 1/3• Interprété• Objet• Multiparadigme• Multiplateforme• Libre, gratuit, etc
  • 3. RUBY 2/3• Ramasse-miettes• Gestion dexceptions• Expressions rationnelles (Regexp)• Blocs• Extensions en C
  • 4. RUBY 3/3• Héritage simple• Mixin -> « héritage multiple »• Réflexion• Crée en 1995
  • 5. VIRTUAL MACHINE• Matzs Ruby Interpreter – Cruby• JRuby• Rubinius• MacRuby• mruby• RubyMotion
  • 6. AUTOUR DU LANGAGE
  • 7. POUR LES DEV• Rspec, Cucumber, Minitest, ...• HAML, SASS, Compass, ...• Pow, Spork, Guard, ...• Bundler, RVM, Rbenv, Pik, ...• Rails, Sinatra, ...• Vagrant
  • 8. POUR LA PRODUCTION• Unicorn, Passenger, ...• Capistrano, Pupetts, Chef, ...• Graylog2, God, ...
  • 9. POUR LES DEV• Cucumber• Guard, SASS, Compass, ...• Vagrant• Graylog2, God, ...
  • 10. ET ENCORE...•+ de 43 667 gems sur RubyGems.org• ruby-toolbox.com
  • 11. RAILS json Rack Uglifier i18nERB ActiveRecord
  • 12. MV C
  • 13. M odel View C ontroller
  • 14. OR M
  • 15. Object R elational Mapping
  • 16. ACTIVE RECORD articlesid title body1 hello world This is a body # app/models/article.rb class Article < ActiveRecord::Base end article = Article.first article.title #=> "hello world"
  • 17. ACTIVE RECORD articlesid title body published1 hello world This is a body 12 other art. Not published 0 articles = Article.where(published: 1) articles.count #=> 1
  • 18. CONFIGURATION
  • 19. ConventionsCONFIGURATION
  • 20. ACTIVE RECORD articlesid title body author_id # app/models/article.rb1 ... ... 1 class Article < ActiveRec... belongs_to :author end # app/models/author.rb class Author < ActiveRec... authors has_many :articles id name end 1 John Doe article = Article.first article.author.name #=> “John Doe”
  • 21. ACTIVE RECORD MySQL PostgreSQL SQLite ...
  • 22. ROUTING# app/controller/hello_controller.rbclass HelloController < ApplicationController def index @name = params[:name] endend http://example.com/hello/John # config/routes.rb get "hello/:name" => "hello#index" action du contrôleur URL contrôleur verbe HTTP paramètre
  • 23. VUES# app/controller/hello_controller.rbclass HelloController < ApplicationController def index @name = params[:name] endend# app/views/hello/index.html.erbBonjour <%= @name %> Conventions !
  • 24. HELPERS# app/controller/articles_controller.rbclass ArticlesController < ApplicationController def new @article = Article.new endend Title <%= form_for @article do |f| %> <p><%= f.label :title, "Title" %><br /> <%= f.text_field :title %></p> Body <p><%= f.label :body, "Body" %><br /> <%= f.text_area :body %></p> <p><%= f.submit %></p> <% end %> Create Article
  • 25. RAILTIES$ rake routesGET /hello/:name { :controller => "hello", :action => "index" }$ rails serverLance un serveur web sur http://localhost:3000/$ rails consoleLance une console avec le contexte de l’application >> Article.first.title #=> "hello world"
  • 26. GÉNÉRATEURS$ rails generate model author name:string invoke active_record create db/migrate/20120108151543_create_authors.rb create app/models/author.rb instructions de création de la table authors modèle Author
  • 27. GÉNÉRATEURS$ rails g scaffold author name:stringcreate db/migrate/20120108152723_create_authors.rbcreate app/models/author.rb modèleroute resources :authors routescreate app/controllers/authors_controller.rb contrôleurcreate app/views/authors/index.html.erbcreate app/views/authors/edit.html.erbcreate app/views/authors/show.html.erbcreate app/views/authors/new.html.erb vuescreate app/views/authors/_form.html.erbcreate public/stylesheets/scaffold.css CSS par défaut
  • 28. GÉNÉRATEURS # config/routes.rb resources :authors authors GET /authors { action: index controller: authors } author GET /authors/:id { action: show controller: authors } new_author GET /authors/new { action: new controller: authors } POST /authors { action: create controller: authors } edit_author GET /authors/:id/edit { action: edit controller: authors } PUT /authors/:id { action: update controller: authors } DELETE /authors/:id { action: destroy controller: authors }<%= link_to "All authors", authors_path %><%= link_to "Edit", edit_author_path(@author) %>
  • 29. GÉNÉRATEURS
  • 30. GÉNÉRATEURS
  • 31. GÉNÉRATEURS
  • 32. GÉNÉRATEURS
  • 33. GÉNÉRATEURS
  • 34. GÉNÉRATEURS
  • 35. GÉNÉRATEURS
  • 36. GÉNÉRATEURS
  • 37. LES PETITS PLUS D’ACTIVESUPPORT1.kilobytes! #=> 10243.days.ago!! #=> Sat, 04 Feb 2012 17:45:42 CET +01:00"héhé test".parameterize! #=> "hehe-test"“article”.pluralize! ! ! #=> "articles" !
  • 38. EXTENSIBILITÉ Grâce aux Gems
  • 39. VUES ET FORMULAIRES<%= form_for @article do |f| %> <p><%= f.label :title, "Title" %><br /> <%= f.text_field :title %></p> <p><%= f.label :body, "Body" %><br /> <%= f.text_area :body %></p> <p><%= f.submit %></p><% end %> slim + simple_form = simple_form_for @article do |f| = f.input :title = f.input :body = f.submit
  • 40. ET TANT D’AUTRESMongoid Pagination MongoDB Kaminari Carierwave Système d’administration Upload de fichiers Active Admin
  • 41. QUI UTILISE RAILS ? Twitter Github BasecampPages Jaunes US Groupon Shopify http://rubyonrails.org/applications
  • 42. J’INSTALLE TOUT ÇA COMMENT ?
  • 43. JRUBY
  • 44. LES RESSOURCES
  • 45. ESSAYER EN LIGNE• tryruby.org• rubykoans.com• rubymonk.com• railsforzombies.org
  • 46. POUR APPRENDRE• hackety.com• ruby.railstutorial.org• railscasts.com• jasimabasheer.com/posts/ meta_introduction_to_ruby.html• www.pierreschambacher.com/blog/lectures-pour- apprendre-ruby-et-rails/
  • 47. A SUIVRE• nicolas.ledez.net @nledez• organicweb.fr @organicweb• camilleroux.com @CamilleRoux• matthieusegret.com @MatthieuSegret• news.humancoders.com @Human_Coders• @brmichel (http://linuxfr.org/)
  • 48. LA COMMUNAUTÉE• Apéros Ruby• rubyfrance.org• railsfrance.org• Google groups:• Rennes on Rails• Railsfrance
  • 49. UN GRAND MERCI•A Simon Courtois• @happynoff• Pour ses slides :• http://blog.happynoff.fr/post/pourquoi-ruby-on-rails-ca-dechire