Slide 1

Slide 1 text

David Padilla @dabit

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

www.magmaconf.com

Slide 4

Slide 4 text

Web applications with Ruby (not Rails)

Slide 5

Slide 5 text

I invented MVC on ASP Classic

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Not really

Slide 8

Slide 8 text

<% set conn=Server.CreateObject("ADODB.Connection") conn.Open "northwind" %> Super App

Page 1

<% ' Some code here that connects to the DB and ' displays stuff %> page1.asp

Slide 9

Slide 9 text

<% set conn=Server.CreateObject("ADODB.Connection") conn.Open "northwind" %> Super App

Another Page

<% ' Some code here that connects to the DB and ' displays stuff %> AnotherPage.asp

Slide 10

Slide 10 text

Index.asp Super App <% page = Request.QueryString("page") Select Case page Case "page1" %> <% Case "AnotherPage" %> <% End Select %>

Slide 11

Slide 11 text

2000

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

MVC

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

http://therantygirl.files.wordpress.com/2012/07/happy-cat.jpg

Slide 16

Slide 16 text

Mid Programmer Life Crisis

Slide 17

Slide 17 text

Programming Web applications with Rails is BORING

Slide 18

Slide 18 text

Building websites with Rails is not ENOUGH programming

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Most of us don’t know what’s going on outside of Rails

Slide 24

Slide 24 text

We used to have all these problems

Slide 25

Slide 25 text

We used to actually write SQL

Slide 26

Slide 26 text

Bring programming back

Slide 27

Slide 27 text

Web applications with Ruby (not Rails)

Slide 28

Slide 28 text

Rack

Slide 29

Slide 29 text

Rack is cool as Bow Ties

Slide 30

Slide 30 text

Web Server Web Application A hash with request headers

Slide 31

Slide 31 text

Web Server Web Application A hash with request headers respond_to(:call)

Slide 32

Slide 32 text

Web Server Web Application A hash with request headers

Slide 33

Slide 33 text

[http_code, headers, body]! Integer Hash Responds to :each

Slide 34

Slide 34 text

Web Server Web Application [http_code, headers, body]!

Slide 35

Slide 35 text

run -> (env) { puts env [200, {}, []] } config.ru

Slide 36

Slide 36 text

Live Code

Slide 37

Slide 37 text

Router

Slide 38

Slide 38 text

/posts PostController #index

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Models

Slide 42

Slide 42 text

ActiveRecord::Base

Slide 43

Slide 43 text

require 'active_record' ! class User < ActiveRecord::Base #... end model/user.rb

Slide 44

Slide 44 text

Sequel

Slide 45

Slide 45 text

model/user.rb require 'sequel' ! DB = Sequel.sqlite ! class User ! def self.all DB[:users].to_a end ! end

Slide 46

Slide 46 text

pg ! mysql

Slide 47

Slide 47 text

model/user.rb require 'pg' ! DB = PG.connect( dbname: 'test', host: 'localhost') ! class User def self.all result = DB.exec "SELECT * FROM users" fields = result.fields result.collect do |row| hash = {} row.each_with_index do |value, i| hash[fields[i]] = value end end end end

Slide 48

Slide 48 text

One last piece of advice

Slide 49

Slide 49 text

Don’t actually do this

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

Logging Caching Database Pooling Sessions Cookies Security

Slide 53

Slide 53 text

Read code

Slide 54

Slide 54 text

Try to understand how things work

Slide 55

Slide 55 text

Write your own framework!

Slide 56

Slide 56 text

<3  Rails Core Team

Slide 57

Slide 57 text

Disclaimer: I do NOT actually think that writing web applications with Rails is BORING

Slide 58

Slide 58 text

github.com/dabit/wawr

Slide 59

Slide 59 text

@dabit [email protected] Thank You!