SlideShare a Scribd company logo
1 of 46
Download to read offline
Ruby Isn’t
Just About Rails

Adam Wiggins
Codemash 2009
?
?
Ruby
You can’t sell a platform
You can’t sell a platform

    ...without a killer app.
A programming
language is a platform
is
the
killer
app Ruby
for
Came for Rails,
stayed for Ruby
An explosion of Ruby
projects in the past 2
years
Let’s take a tour!
Rails is:
ORM - ActiveRecord
Web Layer - ActionPack
Templating - ERB
Test Framework - Test::Unit
ORM
  ActiveRecord
class CreatePosts < ActiveRecord::Migration
  create_table :posts do |t|
     t.string :title
     t.text :body
     t.datetime :created_at
     t.integer :post_id
    end
end

$ rake db:migrate

class Post < ActiveRecord::Base
  has_many :comments
end

Post.find(:first, :conditions =>
          [ quot;title = ?quot;, quot;First postquot; ])
ORM
  ActiveRecord
  DataMapper
  Sequel
Define schema in the code
instead of the database


http://datamapper.org
class Post
  include DataMapper::Resource

  property   :id,           Serial
  property   :title,        String
  property   :body,         Text
  property   :created_at,   DateTime

  has n, :comments
end

DataMapper.auto_upgrade!

Post.first(:title => quot;First Postquot;)
Access a database with
just hashes - or map
models

http://sequel.rubyforge.org
db = Sequel.connect('mysql://root@localhost/db')

db.create_table :posts do
  primary_key :id
  varchar :title
  text :body
  datetime :created_at
end

db[:posts].filter(:title => quot;First Postquot;).first
Web Layer
   ActionPack
ActionController::Routing::Routes.draw do |map|
   map.resource :posts
end

class PostsController < ApplicationController
   def create
      @post = Post.create! params
      redirect_to(@post)
   end

      def show
         @post = Post.find(params[:id])
      end
end
Web Layer
   ActionPack
   Merb
   Sinatra
The hacker’s framework

“No code is faster than no code”


http://merbivore.org
Merb::Router.prepare do |router|
  resource :posts
end

class Posts < Merb::Controller
  def create
    @post = Post.create params
    redirect(url(:post, @post))
  end

  def show
    @post = Post.find(params[:id])
    display @post
  end
end
use_orm :datamapper
use_test :rspec
use_template_engine :erb
Merb 2.0 == Rails 3.0
Sinatra
The classy
microframework for Ruby
“Exposed simplicity instead of
hidden complexity”

http://sinatra.rubyforge.org
require 'rubygems'
require 'sinatra'
require 'lib/posts'

post '/posts'
 post = Post.create! params
 redirect quot;/posts/#{post.id}quot;
end

get '/posts/:id' do
 @post = Post.find(params[:id])
 erb :post
end
Test Framework
Unit tests
TDD
Test-Driven Development
BDD
Behavior-Driven
Development

http://behaviour-driven.org
TATFT
Test All The Darn Time
Test Framework
   Test::Unit
class PostTest < Test::Unit::TestCase

  def test_simple_slug
    post = Post.new :title => quot;First Postquot;
    assert_equal quot;first_postquot;, post.slug
  end

  def test_complex_slug
    post = Post.new :title => quot;My Post!quot;)
    assert_equal quot;my_postquot;, post.slug
  end

end
RSpec
Behavior-Driven
Development


http://rspec.info
describe Post do

  it quot;generates a url slug from the titlequot; do
    post = Post.new :title => quot;First Postquot;
    post.slug.should == quot;first_postquot;
  end

  it quot;drops punctuation from the url slugquot; do
    post = Post.new :title => quot;My Post!quot;
    post.slug.should == quot;my_postquot;
  end

end
$ rake spec:doc
Post
- generates a url slug from the title
- drops punctuation from the url slug
Templating Engine
   ERB
<div class=quot;postquot;>
  <h1><%= @post.title %></h1>
  <div class=quot;bodyquot;>
    <%= @post.body %>
  </div>
</div>
Templating Engine
   ERB
   Haml
Haml
Markup haiku



http://haml.hamptoncatlin.com
.post
  %h1= @post.title
  .body= @post.body
Ties it all together

http://rack.rubyforge.org
The End.


http://adam.blog.heroku.com


Adam Wiggins
Codemash 2009

More Related Content

What's hot

What's hot (20)

Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Capybara with Rspec
Capybara with RspecCapybara with Rspec
Capybara with Rspec
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Nodeconf npm 2011
Nodeconf npm 2011Nodeconf npm 2011
Nodeconf npm 2011
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Rails Metal, Rack, and Sinatra
Rails Metal, Rack, and SinatraRails Metal, Rack, and Sinatra
Rails Metal, Rack, and Sinatra
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
 
Ruby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelRuby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequel
 
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes LaravelWP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
 
Foreman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsForeman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple components
 
Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClient
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Capistrano Overview
Capistrano OverviewCapistrano Overview
Capistrano Overview
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 

Similar to Ruby Isn't Just About Rails

Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
railsconf
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
Raimonds Simanovskis
 

Similar to Ruby Isn't Just About Rails (20)

Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Sinatra
SinatraSinatra
Sinatra
 
Rails Engine | Modular application
Rails Engine | Modular applicationRails Engine | Modular application
Rails Engine | Modular application
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Rack
RackRack
Rack
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gem
 
Capistrano
CapistranoCapistrano
Capistrano
 
2018 RubyHACK: put git to work - increase the quality of your rails project...
2018 RubyHACK:  put git to work -  increase the quality of your rails project...2018 RubyHACK:  put git to work -  increase the quality of your rails project...
2018 RubyHACK: put git to work - increase the quality of your rails project...
 

More from Adam Wiggins (6)

Waza keynote: Idea to Delivery
Waza keynote: Idea to DeliveryWaza keynote: Idea to Delivery
Waza keynote: Idea to Delivery
 
The Epic Pivot: Heroku's Story
The Epic Pivot: Heroku's StoryThe Epic Pivot: Heroku's Story
The Epic Pivot: Heroku's Story
 
Cloud Services
Cloud ServicesCloud Services
Cloud Services
 
Next-Generation Ruby Deployment with Heroku
Next-Generation Ruby Deployment with HerokuNext-Generation Ruby Deployment with Heroku
Next-Generation Ruby Deployment with Heroku
 
Nginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksNginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP Tricks
 
rush, the Ruby shell and Unix integration library
rush, the Ruby shell and Unix integration libraryrush, the Ruby shell and Unix integration library
rush, the Ruby shell and Unix integration library
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

Ruby Isn't Just About Rails