Modern
webdevelopment
with
Ruby on Rails
Robert Glaser
Software Developer at Planetactive
Slide 2
Slide 2 text
Me
• Studied at Fontys Venlo
• 26 years
• Software Developer at Planetactive - an
Ogilvy Company in Düsseldorf
twitter.com/mrreynolds
Slide 3
Slide 3 text
Planetactive
• Ogilvy / WPP worldwide agency group
• Full service digital marketing agency
Slide 4
Slide 4 text
So...
Slide 5
Slide 5 text
Modern?
• What exactly does „modern“ mean?
• „Modern“ is a very subjective and
opinionated term
• So is Ruby on Rails!
Slide 6
Slide 6 text
• 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
Slide 7
Slide 7 text
Wait.
There are hundreds of MVC web
frameworks!
Slide 8
Slide 8 text
„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
ORM
• Database abstraction & persistance ORM
• ActiveRecord also a pattern
• Migrations for incremental schema
management
Slide 12
Slide 12 text
YEAH!
I don‘t have to write
SQL!!!
Slide 13
Slide 13 text
Yes, but you should
understand what you
are doing.
Slide 14
Slide 14 text
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
Slide 15
Slide 15 text
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
Slide 16
Slide 16 text
Model
• Business logic
• Data persistence
• ActiveRecord
Slide 17
Slide 17 text
View
• Data presentation
• User Interaction
• Template language ERB (Embedded Ruby)
• ActionView
Slide 18
Slide 18 text
Controller
• Event handling
• Operation on models
• Redirection and rendering
• ActionController
ActionView
• ERB (Embedded Ruby)
• Javascript generators (AJAX)
• XML templates
• Reusing template elements via partials and
layouts
Slide 22
Slide 22 text
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.)
Slide 23
Slide 23 text
REST
• Representational State Transfer
• Representation of resources with only
HTTP
• Actions on resources defined by HTTP
methods
• Stateless
• No additional transport layer like SOAP
Slide 24
Slide 24 text
REST
Slide 25
Slide 25 text
• 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
Slide 26
Slide 26 text
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
• 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