Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Modern Webdevelopment With Ruby On Rails

1,028 views

Published on

A presentation on Ruby on Rails for Fontys Technical Highschool Venlo (Netherlands)

Published in: Technology
  • Be the first to comment

Modern Webdevelopment With Ruby On Rails

  1. 1. Modern webdevelopment with Ruby on Rails Robert Glaser Software Developer at Planetactive
  2. 2. Me • Studied at Fontys Venlo • 26 years • Software Developer at Planetactive - an Ogilvy Company in Düsseldorf twitter.com/mrreynolds
  3. 3. Planetactive • Ogilvy / WPP worldwide agency group • Full service digital marketing agency
  4. 4. So...
  5. 5. Modern? • What exactly does „modern“ mean? • „Modern“ is a very subjective and opinionated term • So is Ruby on Rails!
  6. 6. • Created in 2004 by David Heinemeier Hansson (DHH) at 37signals • Extracted from Basecamp (basecamphq.com) • Based on pragmatic solutions for common problems • Opinionated software • DRY - Don‘t Repeat Yourself
  7. 7. Wait. There are hundreds of MVC web frameworks!
  8. 8. „It‘s a very pragmatic, very targeted framework with a strong sense of direction. You might not share it‘s vision, but it undeniably has one.“ DHH photo copyright by James Duncan Davidson
  9. 9. Rails is „full stack“... • ActiveRecord (ORM) • ActionPack (ActionController, ActionView) • ActiveSupport (Class Extensions, Helpers) • ActionMailer • ActiveResource (REST Mapper) • Rails (Core Lib)
  10. 10. ...with many ingredients • Instant start defaults • Strong REST support • Webserver • Session Handling • Logger • Middleware (Rack) • Staging • Test Framework • AJAX • Plugins • Webservices • Engines • Mail • Clean MVC architecture • Debugger • Scaffolding • Caching
  11. 11. ORM • Database abstraction & persistance ORM • ActiveRecord also a pattern • Migrations for incremental schema management
  12. 12. YEAH! I don‘t have to write SQL!!!
  13. 13. Yes, but you should understand what you are doing.
  14. 14. Convention over configuration • File naming conventions and assumptions • DB naming conventions for databases, tables, primary- and foreign keys • Pluralization and singularization through String inflectors • Per-Environment configuration files
  15. 15. DRY - Don‘t Repeat Yourself • Table column names don‘t need to be manually defined => read from DB • Reusing code (e.g. in views via partials) • Metaprogramming • DSLs
  16. 16. Model • Business logic • Data persistence • ActiveRecord
  17. 17. View • Data presentation • User Interaction • Template language ERB (Embedded Ruby) • ActionView
  18. 18. Controller • Event handling • Operation on models • Redirection and rendering • ActionController
  19. 19. ActionController ActiveRecord ActionView
  20. 20. ActiveRecord • Conventions (pluralized table names, ...) • Dynamic getters and setters • SQL mostly unnecessary • Entity relations (1:1, 1:n, n:n) • SQL injection protection • Validators • Callbacks
  21. 21. ActionView • ERB (Embedded Ruby) • Javascript generators (AJAX) • XML templates • Reusing template elements via partials and layouts
  22. 22. ActionController • Actions are public controller methods • Automatic template rendering • Multiple formats can easily be supported • RESTful model representations • Callbacks • Complete routing system • Security (CSRF, IP spoofing, etc.)
  23. 23. REST • Representational State Transfer • Representation of resources with only HTTP • Actions on resources defined by HTTP methods • Stateless • No additional transport layer like SOAP
  24. 24. REST
  25. 25. Testing • Test environment & database • Fixtures or Factories, depending on you • Unit tests for models • Functional tests for controllers • Integration tests for workflow • Automated browser tests via Selenium
  26. 26. Made for agile! • Test driven development encouraged • It‘s hard not to test • Coverage testing via rcov • Behaviour driven development with Rspec, Cucumber or Shoulda (Stories and contexts) • Iterative DB schema evolvement via migrations
  27. 27. Libraries, libraries!! • Plugins • Ruby Gems (Ruby‘s package management system)
  28. 28. So, what is Ruby?
  29. 29. Ruby • Released 1995 in Japan • Created by Yukihiro Matsumoto „Matz“ • Ruby should feel „natural, not simple“ • Ruby should be „more powerful than perl, more object-oriented than python“
  30. 30. Everything is an object!
  31. 31. True open classes!
  32. 32. Loops
  33. 33. Loops
  34. 34. Classes, objects, loops, iterators
  35. 35. Symbols
  36. 36. Symbols
  37. 37. Classes & modules
  38. 38. Mixins
  39. 39. Mixins
  40. 40. Metaprogramming
  41. 41. Exceptions
  42. 42. If you want to use Ruby, use it idiomaticly!
  43. 43. Demo time!
  44. 44. Fin! • Diploma thesis? • Practical semester? • Get in touch with me!

×