Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Modern Web Development with Ruby on Rails

Modern Web Development with Ruby on Rails

A Ruby/Rails intro talk I gave at Fontys Technical Highschool Venlo (Netherlands) in March 2009.

Robert Glaser

November 15, 2011
Tweet

More Decks by Robert Glaser

Other Decks in Programming

Transcript

  1. Me • Studied at Fontys Venlo • 26 years •

    Software Developer at Planetactive - an Ogilvy Company in Düsseldorf twitter.com/mrreynolds
  2. Modern? • What exactly does „modern“ mean? • „Modern“ is

    a very subjective and opinionated term • So is Ruby on Rails!
  3. • 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
  4. „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
  5. Rails is „full stack“... • ActiveRecord (ORM) • ActionPack (ActionController,

    ActionView) • ActiveSupport (Class Extensions, Helpers) • ActionMailer • ActiveResource (REST Mapper) • Rails (Core Lib)
  6. ...with many ingredients • Instant start defaults • Webserver •

    Logger • Staging • AJAX • Webservices • Mail • Debugger • Caching • Strong REST support • Session Handling • Middleware (Rack) • Test Framework • Plugins • Engines • Clean MVC architecture • Scaffolding
  7. ORM • Database abstraction & persistance ORM • ActiveRecord also

    a pattern • Migrations for incremental schema management
  8. 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
  9. 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
  10. 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
  11. ActionView • ERB (Embedded Ruby) • Javascript generators (AJAX) •

    XML templates • Reusing template elements via partials and layouts
  12. 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.)
  13. REST • Representational State Transfer • Representation of resources with

    only HTTP • Actions on resources defined by HTTP methods • Stateless • No additional transport layer like SOAP
  14. • 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 Testing
  15. 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
  16. • 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“ Ruby
  17. Demo time! 1) App erzeugen 2) Scaffold generieren 3) Resource

    generieren 4) Migration zeigen + ausführen 5) Fixtures 6) View zeigen 7) Controller zeigen 8) Model Methoden hinzufügen 9) Unit Test 10) REST erklären 11) named_scope