Classy Web Development with

Ruby, Sinatra
and Heroku
Get a site online in five minutes
            or less.
But first...
serve
serve
Get a site online* in 5 seconds!
serve
Get a site online* in 5 seconds!
                         *localhost
rob$ serve
rob$ serve
[2010-03-23 11:35:38] INFO   WEBrick 1.3.1
[2010-03-23 11:35:38] INFO   ruby 1.8.7 (2008-08-11)
[2010-03-23 11:...
rob$ serve
[2010-03-23 11:35:38] INFO   WEBrick 1.3.1
[2010-03-23 11:35:38] INFO   ruby 1.8.7 (2008-08-11)
[2010-03-23 11:...
rob$ serve
[2010-03-23 11:35:38] INFO   WEBrick 1.3.1
[2010-03-23 11:35:38] INFO   ruby 1.8.7 (2008-08-11)
[2010-03-23 11:...
rob$ serve
[2010-03-23 11:35:38] INFO   WEBrick 1.3.1
[2010-03-23 11:35:38] INFO   ruby 1.8.7 (2008-08-11)
[2010-03-23 11:...
rob$ serve
[2010-03-23 11:35:38] INFO WEBrick 1.3.1
[2010-03-23 11:35:38] INFO ruby 1.8.7 (2008-08-11)
[2010-03-23 11:35:3...
demo
 serve
questions?
Sinatra
hi.rb
-----
require 'rubygems'
require 'sinatra'
get '/hi' do
  "Hello World!"
end
rob$ ruby hi.rb
rob$ ruby hi.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with
backup from Thin
>> Thin web server (v1....
rob$ ruby hi.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with
backup from Thin
>> Thin web server (v1....
rob$ ruby hi.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with
backup from Thin
>> Thin web server (v1....
hi.rb
-----
require 'rubygems'
require 'sinatra'
get '/hi' do
  "Hello World!"
end
rob$ ruby hi.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with
backup from Thin
>> Thin web server (v1....
rob$ ruby hi.rb
== Sinatra/0.9.4 has taken the stage on 4567 for development with
backup from Thin
>> Thin web server (v1....
demo
sinatra/hi
require 'rubygems'
require 'sinatra'
get '/hi' do
  "Hello World!"
end
require 'rubygems'   Ruby package manager
require 'sinatra'
get '/hi' do
  "Hello World!"
end
require 'rubygems'   Ruby package manager
require 'sinatra'    Sinatra package (gem)
get '/hi' do
  "Hello World!"
end
require 'rubygems'   Ruby package manager
require 'sinatra'    Sinatra package (gem)
get '/hi' do         GET request to /...
require 'rubygems'   Ruby package manager
require 'sinatra'    Sinatra package (gem)
get '/hi' do         GET request to /...
get '/hi' do
  "Hello World!"
end
}
get '/hi' do
  "Hello World!"       “block”
end
}
get '/hi' do           Whatever is returned from
  "Hello World!"       the block is sent to the
end                    ...
Where’s the return?
In Ruby, if you don’t say “return,”
            it’s implied.
In Ruby, if you don’t say “return”
            it’s implied.


The last statement in a block is
       always returned.
get '/hi' do
  "Hello World!"
end
=
get '/hi' do
  "Hello World!"
end
=
get '/hi' do           get '/hi' do
  "Hello World!"         return "Hello World!"
end                    end
A slightly more complex example
beta.rb
-------
require 'rubygems'
require 'sinatra'

get '/' do
  html = '<p>Welcome! Leave your email address for more i...
demo
sinatra/beta1
Views
`-- beta.rb



|-- beta.rb
`-- views
    |-- index.erb
    `-- submit.erb
erb
Embedded Ruby
beta.rb
-------
require 'rubygems'
require 'sinatra'

get '/' do
  erb :index
end

post '/submit' do
  erb :submit
end
beta.rb
-------
require 'rubygems'
require 'sinatra'

get '/' do
  erb :index
end

post '/submit' do
  erb :submit
end



...
beta.rb
-------
require 'rubygems'
require 'sinatra'

get '/' do
  erb :index
end

post '/submit' do
  erb :submit
end



...
demo
sinatra/beta2
Layouts
|-- beta.rb
`-- views
    |-- index.erb
    |-- layout.erb
    `-- submit.erb
views/layout.rb
---------------
<!DOCTYPE html>
<html>
<head>
  <title>Beta Info</title>
</head>
<body>
  <%= yield %>
</b...
views/layout.rb
---------------
<!DOCTYPE html>
<html>
<head>
  <title>Beta Info</title>
</head>
<body>
  <%= yield %>
</b...
views/layout.rb
---------------
<!DOCTYPE html>
<html>
<head>
  <title>Beta Info</title>
</head>
<body>
  <%= yield %>
</b...
demo
sinatra/beta3
Static Content
 Images, stylesheets and Javascript
|-- beta.rb
`-- views
    |-- index.erb
    |-- layout.erb
    `-- submit.erb
|-- beta.rb
|-- public
`-- views
    |-- index.erb
    |-- layout.erb
    `-- submit.erb
|--   beta.rb
|--   public
|     `-- stylesheets
|         `-- shared.css
`--   views
      |-- index.erb
      |-- layout...
demo
sinatra/beta4
So
So
1. Every URL you want to respond to goes in your .rb file
So
1. Every URL you want to respond to goes in your .rb file

2. Pages themselves go in /views as .erb files
So
1. Every URL you want to respond to goes in your .rb file

2. Pages themselves go in /views as .erb files

3. Wrapping la...
So
1. Every URL you want to respond to goes in your .rb file

2. Pages themselves go in /views as .erb files

3. Wrapping la...
But
But
If all you have is static web pages, no need to
   add every path to your sinatra .rb file and
             copy the co...
But
If all you have is static web pages, no need to
   add every path to your sinatra .rb file and
             copy the co...
But
If all you have is static web pages, no need to
   add every path to your sinatra .rb file and
             copy the co...
Dynamic URLs?
dynamic.rb
----------
require 'rubygems'
require 'sinatra'

get '/' do
  'This is the homepage'
end

get '/:city' do
  'Th...
demo
sinatra/dynamic
questions?
Heroku
Kind of like EC2 but specific to
Ruby-based web applications
Run your application/website
          for free
Heroku relies on Git.
Git
Like subversion, but more powerful (and complex)
rob$ git init .
rob$ git init .
Initialized empty Git repository in /Users/rob/Dropbox/Active
University/sinatra/heroku1/.git/
rob$ git init .
Initialized empty Git repository in /Users/rob/Dropbox/Active
University/sinatra/heroku1/.git/

rob$ git a...
rob$ git init .
Initialized empty Git repository in /Users/rob/Dropbox/Active
University/sinatra/heroku1/.git/

rob$ git a...
rob$ git init .
Initialized empty Git repository in /Users/rob/Dropbox/Active
University/sinatra/heroku1/.git/

rob$ git a...
Our app is version controlled
rob$ heroku create
rob$ heroku create
Creating blooming-sunrise-28... done!
Created http://blooming-sunrise-28.heroku.com/ |
git@heroku.com:b...
rob$ heroku create
Creating blooming-sunrise-28... done!
Created http://blooming-sunrise-28.heroku.com/ |
git@heroku.com:b...
rob$ heroku create
Creating blooming-sunrise-28... done!
Created http://blooming-sunrise-28.heroku.com/ |
git@heroku.com:b...
demo
sinatra/heroku1
One thing missing
One thing missing


config.ru
|--   beta.rb
|--   config.ru
|--   public
|     `-- stylesheets
|         `-- shared.css
`--   views
      |-- index.erb
...
config.ru
---------
require 'beta'
run Sinatra::Application
rob$ git add .
rob$ git add .

rob$ git commit -m 'Added config.ru file for heroku'
rob$ git add .

rob$ git commit -m 'Added config.ru file for heroku'
[master 7b8ab4f] Added config.ru file for heroku
 1 f...
rob$ git add .

rob$ git commit -m 'Added config.ru file for heroku'
[master 7b8ab4f] Added config.ru file for heroku
 1 f...
rob$ git add .

rob$ git commit -m 'Added config.ru file for heroku'
[master 7b8ab4f] Added config.ru file for heroku
 1 f...
demo
sinatra/heroku2
So
So
1. Get your app working in development
So
1. Get your app working in development

2. Add a config.ru file
So
1. Get your app working in development

2. Add a config.ru file

3. git init . (only the first time)
So
1. Get your app working in development

2. Add a config.ru file

3. git init . (only the first time)

4. git add .
So
1. Get your app working in development

2. Add a config.ru file

3. git init . (only the first time)

4. git add .

5. git...
So
1. Get your app working in development

2. Add a config.ru file

3. git init . (only the first time)

4. git add .

5. git...
So
1. Get your app working in development

2. Add a config.ru file

3. git init . (only the first time)

4. git add .

5. git...
questions?
Installation
Ruby 1.8.6 or higher
http://ruby-lang.org

Rubygems 1.3.6
http://rubyforge.org/projects/rubygems

Get Serve, ...
Resources
Ruby Homepage
http://ruby-lang.org

Sinatra Homepage
http://www.sinatrarb.com

Heroku Homepage
http://heroku.com...
The End
Classy Web Development With Ruby, Sinatra And Heroku
Classy Web Development With Ruby, Sinatra And Heroku
Classy Web Development With Ruby, Sinatra And Heroku
Upcoming SlideShare
Loading in...5
×

Classy Web Development With Ruby, Sinatra And Heroku

22,326

Published on

Using Sinatra and Heroku to quickly get your website online

Published in: Technology
3 Comments
26 Likes
Statistics
Notes
  • coolll
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • This is a great introduction, really appreciate the simple walk through. Addresses this common issue much better: http://stackoverflow.com/questions/2437390/serving-static-files-with-sinatra
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • The application would crash until I added a gemfile... e.g. for anyone out there who’s having a problem create a file called Gemfile in the directory with the following 2 lines in it: 1. source :rubyforge 2. gem ’sinatra’, ’1.1.0’ That's it! Then run: bundle install, add it to git, commit, push to heroku and you should be good!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
22,326
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
322
Comments
3
Likes
26
Embeds 0
No embeds

No notes for slide

Classy Web Development With Ruby, Sinatra And Heroku

  1. 1. Classy Web Development with Ruby, Sinatra and Heroku Get a site online in five minutes or less.
  2. 2. But first...
  3. 3. serve
  4. 4. serve Get a site online* in 5 seconds!
  5. 5. serve Get a site online* in 5 seconds! *localhost
  6. 6. rob$ serve
  7. 7. rob$ serve [2010-03-23 11:35:38] INFO WEBrick 1.3.1 [2010-03-23 11:35:38] INFO ruby 1.8.7 (2008-08-11) [2010-03-23 11:35:38] INFO Serve::Server#start: pid=63741 port=4000
  8. 8. rob$ serve [2010-03-23 11:35:38] INFO WEBrick 1.3.1 [2010-03-23 11:35:38] INFO ruby 1.8.7 (2008-08-11) [2010-03-23 11:35:38] INFO Serve::Server#start: pid=63741 port=4000
  9. 9. rob$ serve [2010-03-23 11:35:38] INFO WEBrick 1.3.1 [2010-03-23 11:35:38] INFO ruby 1.8.7 (2008-08-11) [2010-03-23 11:35:38] INFO Serve::Server#start: pid=63741 port=4000 http://localhost:4000
  10. 10. rob$ serve [2010-03-23 11:35:38] INFO WEBrick 1.3.1 [2010-03-23 11:35:38] INFO ruby 1.8.7 (2008-08-11) [2010-03-23 11:35:38] INFO Serve::Server#start: pid=63741 port=4000 http://localhost:4000
  11. 11. rob$ serve [2010-03-23 11:35:38] INFO WEBrick 1.3.1 [2010-03-23 11:35:38] INFO ruby 1.8.7 (2008-08-11) [2010-03-23 11:35:38] INFO Serve::Server#start: pid=63741 port=4000 localhost - - [23/Mar/2010:11:54:40 PDT] "GET / HTTP/1.1" 200 0 - -> / localhost - - [23/Mar/2010:11:54:40 PDT] "GET /stylesheets/reset- fonts.css HTTP/1.1" 200 0 http://localhost:4000/ -> /stylesheets/reset-fonts.css localhost - - [23/Mar/2010:11:54:40 PDT] "GET /stylesheets/ screen.css HTTP/1.1" 200 0 http://localhost:4000/ -> /stylesheets/screen.css localhost - - [23/Mar/2010:11:54:40 PDT] "GET /stylesheets/ syntax.css HTTP/1.1" 200 0 http://localhost:4000/ -> /stylesheets/syntax.css localhost - - [23/Mar/2010:11:54:40 PDT] "GET /javascripts/ prototype.js HTTP/1.1" 200 0 http://localhost:4000/ -> /javascripts/prototype.js localhost - - [23/Mar/2010:11:54:40 PDT] "GET /javascripts/ effects.js HTTP/1.1" 200 0 http://localhost:4000/ -> /javascripts/effects.js localhost - - [23/Mar/2010:11:54:40 PDT] "GET /javascripts/stack.js HTTP/1.1" 200 0 http://localhost:4000/ -> /javascripts/stack.js [2010-03-23 11:54:41] ERROR `/favicon.ico' not found. localhost - - [23/Mar/2010:11:54:41 PDT] "GET /favicon.ico HTTP/1.1" 404 281
  12. 12. demo serve
  13. 13. questions?
  14. 14. Sinatra
  15. 15. hi.rb ----- require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  16. 16. rob$ ruby hi.rb
  17. 17. rob$ ruby hi.rb == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.2.4 codename Flaming Astroboy) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:4567, CTRL+C to stop
  18. 18. rob$ ruby hi.rb == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.2.4 codename Flaming Astroboy) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:4567, CTRL+C to stop
  19. 19. rob$ ruby hi.rb == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.2.4 codename Flaming Astroboy) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:4567, CTRL+C to stop http://localhost:4567
  20. 20. hi.rb ----- require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  21. 21. rob$ ruby hi.rb == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.2.4 codename Flaming Astroboy) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:4567, CTRL+C to stop http://localhost:4567/hi
  22. 22. rob$ ruby hi.rb == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.2.4 codename Flaming Astroboy) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:4567, CTRL+C to stop http://localhost:4567/hi
  23. 23. demo sinatra/hi
  24. 24. require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end
  25. 25. require 'rubygems' Ruby package manager require 'sinatra' get '/hi' do "Hello World!" end
  26. 26. require 'rubygems' Ruby package manager require 'sinatra' Sinatra package (gem) get '/hi' do "Hello World!" end
  27. 27. require 'rubygems' Ruby package manager require 'sinatra' Sinatra package (gem) get '/hi' do GET request to /hi "Hello World!" end
  28. 28. require 'rubygems' Ruby package manager require 'sinatra' Sinatra package (gem) get '/hi' do GET request to /hi "Hello World!" Respond with text end
  29. 29. get '/hi' do "Hello World!" end
  30. 30. } get '/hi' do "Hello World!" “block” end
  31. 31. } get '/hi' do Whatever is returned from "Hello World!" the block is sent to the end browser
  32. 32. Where’s the return?
  33. 33. In Ruby, if you don’t say “return,” it’s implied.
  34. 34. In Ruby, if you don’t say “return” it’s implied. The last statement in a block is always returned.
  35. 35. get '/hi' do "Hello World!" end
  36. 36. = get '/hi' do "Hello World!" end
  37. 37. = get '/hi' do get '/hi' do "Hello World!" return "Hello World!" end end
  38. 38. A slightly more complex example
  39. 39. beta.rb ------- require 'rubygems' require 'sinatra' get '/' do html = '<p>Welcome! Leave your email address for more info!</p>' html += '<form method="post" action="/submit">' html += '<input type="text" name="email" /><input type="submit" /></form>' return html end post '/submit' do html = '<p>Thank you for your submission!</p>' html += '<p>We will email ' + params['email'] html += ' when we are ready to launch!</p>' return html end
  40. 40. demo sinatra/beta1
  41. 41. Views
  42. 42. `-- beta.rb |-- beta.rb `-- views |-- index.erb `-- submit.erb
  43. 43. erb Embedded Ruby
  44. 44. beta.rb ------- require 'rubygems' require 'sinatra' get '/' do erb :index end post '/submit' do erb :submit end
  45. 45. beta.rb ------- require 'rubygems' require 'sinatra' get '/' do erb :index end post '/submit' do erb :submit end views/index.erb --------------- <p>Welcome! Leave your email address for more info!</p> <form method="post" action="/submit"> <input type="text" name="email" /> <input type="submit" /> </form>
  46. 46. beta.rb ------- require 'rubygems' require 'sinatra' get '/' do erb :index end post '/submit' do erb :submit end views/index.erb --------------- <p>Welcome! Leave your email address for more info!</p> <form method="post" action="/submit"> <input type="text" name="email" /> <input type="submit" /> </form> views/submit.erb ---------------- <p>Thank you for your submission!</p> <p>We will email <%= params['email'] %> when we are ready to launch!</p>
  47. 47. demo sinatra/beta2
  48. 48. Layouts
  49. 49. |-- beta.rb `-- views |-- index.erb |-- layout.erb `-- submit.erb
  50. 50. views/layout.rb --------------- <!DOCTYPE html> <html> <head> <title>Beta Info</title> </head> <body> <%= yield %> </body> </html>
  51. 51. views/layout.rb --------------- <!DOCTYPE html> <html> <head> <title>Beta Info</title> </head> <body> <%= yield %> </body> </html> views/index.erb --------------- <p>Welcome! Leave your email address for more info!</p> <form method="post" action="/submit"> <input type="text" name="email" /> <input type="submit" /> </form>
  52. 52. views/layout.rb --------------- <!DOCTYPE html> <html> <head> <title>Beta Info</title> </head> <body> <%= yield %> </body> </html> views/index.erb --------------- <p>Welcome! Leave your email address for more info!</p> <form method="post" action="/submit"> <input type="text" name="email" /> <input type="submit" /> </form>
  53. 53. demo sinatra/beta3
  54. 54. Static Content Images, stylesheets and Javascript
  55. 55. |-- beta.rb `-- views |-- index.erb |-- layout.erb `-- submit.erb
  56. 56. |-- beta.rb |-- public `-- views |-- index.erb |-- layout.erb `-- submit.erb
  57. 57. |-- beta.rb |-- public | `-- stylesheets | `-- shared.css `-- views |-- index.erb |-- layout.erb `-- submit.erb
  58. 58. demo sinatra/beta4
  59. 59. So
  60. 60. So 1. Every URL you want to respond to goes in your .rb file
  61. 61. So 1. Every URL you want to respond to goes in your .rb file 2. Pages themselves go in /views as .erb files
  62. 62. So 1. Every URL you want to respond to goes in your .rb file 2. Pages themselves go in /views as .erb files 3. Wrapping layout goes in /views/layout.erb
  63. 63. So 1. Every URL you want to respond to goes in your .rb file 2. Pages themselves go in /views as .erb files 3. Wrapping layout goes in /views/layout.erb 4. Static files go in /public
  64. 64. But
  65. 65. But If all you have is static web pages, no need to add every path to your sinatra .rb file and copy the code to /views
  66. 66. But If all you have is static web pages, no need to add every path to your sinatra .rb file and copy the code to /views Just put them in /public
  67. 67. But If all you have is static web pages, no need to add every path to your sinatra .rb file and copy the code to /views Just put them in /public The .rb file is more for dynamic URLs or gathering form fields for use later
  68. 68. Dynamic URLs?
  69. 69. dynamic.rb ---------- require 'rubygems' require 'sinatra' get '/' do 'This is the homepage' end get '/:city' do 'This is the ' + params['city'] + ' homepage' end
  70. 70. demo sinatra/dynamic
  71. 71. questions?
  72. 72. Heroku
  73. 73. Kind of like EC2 but specific to Ruby-based web applications
  74. 74. Run your application/website for free
  75. 75. Heroku relies on Git.
  76. 76. Git Like subversion, but more powerful (and complex)
  77. 77. rob$ git init .
  78. 78. rob$ git init . Initialized empty Git repository in /Users/rob/Dropbox/Active University/sinatra/heroku1/.git/
  79. 79. rob$ git init . Initialized empty Git repository in /Users/rob/Dropbox/Active University/sinatra/heroku1/.git/ rob$ git add .
  80. 80. rob$ git init . Initialized empty Git repository in /Users/rob/Dropbox/Active University/sinatra/heroku1/.git/ rob$ git add . rob$ git commit -m ‘First commit’
  81. 81. rob$ git init . Initialized empty Git repository in /Users/rob/Dropbox/Active University/sinatra/heroku1/.git/ rob$ git add . rob$ git commit -m ‘First commit’ [master (root-commit) d2f7469] First commit 5 files changed, 31 insertions(+), 0 deletions(-) create mode 100644 beta.rb create mode 100644 public/stylesheets/shared.css create mode 100644 views/index.erb create mode 100644 views/layout.erb create mode 100644 views/submit.erb
  82. 82. Our app is version controlled
  83. 83. rob$ heroku create
  84. 84. rob$ heroku create Creating blooming-sunrise-28... done! Created http://blooming-sunrise-28.heroku.com/ | git@heroku.com:blooming-sunrise-28.git Git remote heroku added
  85. 85. rob$ heroku create Creating blooming-sunrise-28... done! Created http://blooming-sunrise-28.heroku.com/ | git@heroku.com:blooming-sunrise-28.git Git remote heroku added rob$ git push heroku master
  86. 86. rob$ heroku create Creating blooming-sunrise-28... done! Created http://blooming-sunrise-28.heroku.com/ | git@heroku.com:blooming-sunrise-28.git Git remote heroku added rob$ git push heroku master Counting objects: 10, done. Delta compression using up to 2 threads. Compressing objects: 100% (8/8), done. Writing objects: 100% (10/10), 1009 bytes, done. Total 10 (delta 0), reused 0 (delta 0) -----> Heroku receiving push ! Heroku push rejected, no Rails or Rack app detected. error: hooks/pre-receive exited with error code 1 To git@heroku.com:blooming-sunrise-28.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:blooming- sunrise-28.git'
  87. 87. demo sinatra/heroku1
  88. 88. One thing missing
  89. 89. One thing missing config.ru
  90. 90. |-- beta.rb |-- config.ru |-- public | `-- stylesheets | `-- shared.css `-- views |-- index.erb |-- layout.erb `-- submit.erb
  91. 91. config.ru --------- require 'beta' run Sinatra::Application
  92. 92. rob$ git add .
  93. 93. rob$ git add . rob$ git commit -m 'Added config.ru file for heroku'
  94. 94. rob$ git add . rob$ git commit -m 'Added config.ru file for heroku' [master 7b8ab4f] Added config.ru file for heroku 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 config.ru
  95. 95. rob$ git add . rob$ git commit -m 'Added config.ru file for heroku' [master 7b8ab4f] Added config.ru file for heroku 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 config.ru rob$ git push heroku master
  96. 96. rob$ git add . rob$ git commit -m 'Added config.ru file for heroku' [master 7b8ab4f] Added config.ru file for heroku 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 config.ru rob$ git push heroku master Counting objects: 13, done. Delta compression using up to 2 threads. Compressing objects: 100% (10/10), done. Writing objects: 100% (13/13), 1.27 KiB, done. Total 13 (delta 1), reused 0 (delta 0) -----> Heroku receiving push -----> Sinatra app detected Compiled slug size is 4K -----> Launching..... done http://blooming-sunrise-28.heroku.com deployed to Heroku To git@heroku.com:blooming-sunrise-28.git * [new branch] master -> master
  97. 97. demo sinatra/heroku2
  98. 98. So
  99. 99. So 1. Get your app working in development
  100. 100. So 1. Get your app working in development 2. Add a config.ru file
  101. 101. So 1. Get your app working in development 2. Add a config.ru file 3. git init . (only the first time)
  102. 102. So 1. Get your app working in development 2. Add a config.ru file 3. git init . (only the first time) 4. git add .
  103. 103. So 1. Get your app working in development 2. Add a config.ru file 3. git init . (only the first time) 4. git add . 5. git commit -m ‘message’
  104. 104. So 1. Get your app working in development 2. Add a config.ru file 3. git init . (only the first time) 4. git add . 5. git commit -m ‘message’ 6. heroku create (only the first time)
  105. 105. So 1. Get your app working in development 2. Add a config.ru file 3. git init . (only the first time) 4. git add . 5. git commit -m ‘message’ 6. heroku create (only the first time) 7. git push heroku master
  106. 106. questions?
  107. 107. Installation Ruby 1.8.6 or higher http://ruby-lang.org Rubygems 1.3.6 http://rubyforge.org/projects/rubygems Get Serve, Sinatra and Heroku gems gem install serve sinatra heroku Git http://git-scm.com/download
  108. 108. Resources Ruby Homepage http://ruby-lang.org Sinatra Homepage http://www.sinatrarb.com Heroku Homepage http://heroku.com Git Homepage http://git-scm.com Example Code http://empty-journey-91.heroku.com/
  109. 109. The End
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×