Demystifying Ruby on Rails
Johan Pretorius
Pretoria.rb - 20 August 2014
rubyonrails.org
de·mys·ti·fy
Scratching the surface is more like it :-)
In 30-45 minutes?
verb
make (a subject) clearer and easier
to unde...
Philosophy
Don’t Repeat Yourself - DRY
“Every piece of knowledge must have
a single unambiguous, authoritative
representat...
Philosophy
Convention over Configuration
Rails is opinionated software, and
defaults to this set of conventions.
Bootstrapping
• Linux or Mac OS X
• Ruby 2.1.2 (rvm / rbenv)
• Rails 4.1.x (4.1.4)
• Sublime Text / vim / Rubymine
• oh-my...
Bootstrapping
Application Generators
• Rails Composer
• Thoughtbot Suspenders
• Renderedtext base-app
Bootstrapping
Rails Composer Starter Apps
• rails-bootstrap
• rails-omniauth
• rails-devise
• roll your own
Bootstrapping
Rails Composer Options #1
• web server
• database
• template engine
• test framework
• front-end framework
Bootstrapping
Rails Composer Options #2
• email setup
• authentication
• authorization
• environment variables
• deployment
Three Steps to Heaven
• rails new bookapp -m composer.rb
• cd bookapp
• thin start
Eddie Ochran, 1960: Three Steps to Heav...
Bootstrapping
Rails Internal Generators
• rails generate
• rails generate model
• rails generate controller
Active Record
The Active Record Pattern
• object wraps a database row/view
• encapsulates database access
• adds domain lo...
Active Record
Convention over Configuration
• naming conventions
• schema conventions
• query interface
Action Controller
Again, smart conventions
• naming conventions
• methods & actions
• parameters
• sessions & cookies
• XM...
Action View
Browser UI
• controllers render views
• layouts: yield & content_for
• assets and partials
• form helpers
Asset Pipeline
What is the Asset Pipeline?
• concatenate JS/CSS
• development vs production
• organize application assets
...
Extending Rails
RubyGem and Bundler
• bundler.io
• the Gemfile
• useful gems
Deployment
Deploying Rails applications is easy
• automate with capistrano
• Heroku
• Digital Ocean
• Amazon Web Services
Configuring Rails
Adjust application behaviour
• Initializer files
• ORM configs
• Rails environments
• Internationalization...
Debugging
Debugging utilities
• pry (binding.pry)
• log files
• rails-footnotes
• debug(params)
Rails on Rack
Rails integration with Rack
• rack.github.io
• active admin
• resque web interface
• comfortable mexican sofa
Resque Web
require ‘resque/server'
mount Resque::Server.new, at: "/resque"
config/routes.rb
Active Admin
config/routes.rb
ActiveAdmin.routes(self)
Comfortable Mexican Sofa
ComfortableMexicanSofa::Routing.admin
(:path => '/cms-admin')
# Make sure this routeset is defined...
Resources #1
Ruby on Rails Guides
Rails Composer
thoughtbot/suspenders
Ruby Version Manager
Rails Release Notes
Resources #2
Manning
Ruby Guides
Planet Ruby on Rails
Stackoverflow
RailsBridge
O'Reilly
Rails Tutorial
Avdi's Ruby Tapas
r...
Rails Reading
Agile Web Development with Rails
Crafting Rails 4 Applications
Growing Rails Applications in Practice
The Ra...
About me
flickr -> qoolpix
twitter
instagram -> qoolpix
about.me/johanpretorius
-> @johan__
rails/rails punchcard
Upcoming SlideShare
Loading in …5
×

Demystifying Ruby on Rails

664 views

Published on

Presentation given at a recent Pretoria.rb meetup: http://www.meetup.com/pretoria-rb/events/197294922/

Published in: Software
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
664
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Demystifying Ruby on Rails

  1. 1. Demystifying Ruby on Rails Johan Pretorius Pretoria.rb - 20 August 2014 rubyonrails.org
  2. 2. de·mys·ti·fy Scratching the surface is more like it :-) In 30-45 minutes? verb make (a subject) clearer and easier to understand.
  3. 3. Philosophy Don’t Repeat Yourself - DRY “Every piece of knowledge must have a single unambiguous, authoritative representation within a system.”
  4. 4. Philosophy Convention over Configuration Rails is opinionated software, and defaults to this set of conventions.
  5. 5. Bootstrapping • Linux or Mac OS X • Ruby 2.1.2 (rvm / rbenv) • Rails 4.1.x (4.1.4) • Sublime Text / vim / Rubymine • oh-my-zsh / git Our Development Environment
  6. 6. Bootstrapping Application Generators • Rails Composer • Thoughtbot Suspenders • Renderedtext base-app
  7. 7. Bootstrapping Rails Composer Starter Apps • rails-bootstrap • rails-omniauth • rails-devise • roll your own
  8. 8. Bootstrapping Rails Composer Options #1 • web server • database • template engine • test framework • front-end framework
  9. 9. Bootstrapping Rails Composer Options #2 • email setup • authentication • authorization • environment variables • deployment
  10. 10. Three Steps to Heaven • rails new bookapp -m composer.rb • cd bookapp • thin start Eddie Ochran, 1960: Three Steps to Heaven Bootstrapping
  11. 11. Bootstrapping Rails Internal Generators • rails generate • rails generate model • rails generate controller
  12. 12. Active Record The Active Record Pattern • object wraps a database row/view • encapsulates database access • adds domain logic on that data Martin Fowler: http://www.martinfowler.com/eaaCatalog/activeRecord.html
  13. 13. Active Record Convention over Configuration • naming conventions • schema conventions • query interface
  14. 14. Action Controller Again, smart conventions • naming conventions • methods & actions • parameters • sessions & cookies • XML & JSON data
  15. 15. Action View Browser UI • controllers render views • layouts: yield & content_for • assets and partials • form helpers
  16. 16. Asset Pipeline What is the Asset Pipeline? • concatenate JS/CSS • development vs production • organize application assets • package assets with a gem
  17. 17. Extending Rails RubyGem and Bundler • bundler.io • the Gemfile • useful gems
  18. 18. Deployment Deploying Rails applications is easy • automate with capistrano • Heroku • Digital Ocean • Amazon Web Services
  19. 19. Configuring Rails Adjust application behaviour • Initializer files • ORM configs • Rails environments • Internationalization (I18n)
  20. 20. Debugging Debugging utilities • pry (binding.pry) • log files • rails-footnotes • debug(params)
  21. 21. Rails on Rack Rails integration with Rack • rack.github.io • active admin • resque web interface • comfortable mexican sofa
  22. 22. Resque Web require ‘resque/server' mount Resque::Server.new, at: "/resque" config/routes.rb
  23. 23. Active Admin config/routes.rb ActiveAdmin.routes(self)
  24. 24. Comfortable Mexican Sofa ComfortableMexicanSofa::Routing.admin (:path => '/cms-admin') # Make sure this routeset is defined last ComfortableMexicanSofa::Routing.content (:path => '/home', :sitemap => false) config/routes.rb
  25. 25. Resources #1 Ruby on Rails Guides Rails Composer thoughtbot/suspenders Ruby Version Manager Rails Release Notes
  26. 26. Resources #2 Manning Ruby Guides Planet Ruby on Rails Stackoverflow RailsBridge O'Reilly Rails Tutorial Avdi's Ruby Tapas rails / rails Pragmatic
  27. 27. Rails Reading Agile Web Development with Rails Crafting Rails 4 Applications Growing Rails Applications in Practice The Rails 4 Way Rails AntiPatterns Rails 4 In Action
  28. 28. About me flickr -> qoolpix twitter instagram -> qoolpix about.me/johanpretorius -> @johan__
  29. 29. rails/rails punchcard

×