Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sinatra: My Way

Sinatra: My Way

How I'm using Sinatra: structure and useful scripts

Matthew Conway

July 19, 2012

More Decks by Matthew Conway

Other Decks in Programming


  1. SINATRA my way

  2. MATTHEW CONWAY @mattonrails

  3. what is this? why am i here?

  4. we’re going to learn you some standards! sinatra: you’re great.

  5. we’re going to learn you some standards! sinatra: you’re great.

    but (yeah, don’t tell him i said that)
  6. to avoid confusion, we need to make some rules...

  7. not ‘all the time’ rules, but within an application

  8. ring-a ding-ding

  9. you need... more structure handy scripts

  10. so... we’re doin it your way?

  11. (frank’s a smart guy)


  13. classic style modular style not

  14. the simple app

  15. Gemfile Procfile app.rb config.ru script/

  16. # Gemfile source :rubygems gem ‘sinatra’ gem ‘foreman’ gem ‘unicorn’

    group :development do gem ‘shotgun’ gem ‘thin’ end
  17. # Procfile web: bundle exec unicorn --port $PORT

  18. # app.rb module Haiku class App < Sinatra::Base get ‘/’

    do @haiku = Redis.srandmember(‘haiku’) haml :home end ... end end
  19. # config.ru require ‘./app’ run Haiku::App

  20. as it grows

  21. Gemfile Procfile Rakefile app/ config/ config.ru db/ script/

  22. Com Fl With M ...or collaborate with me ...or something

  23. where do I start?

  24. is bundler installed? do i have the required ruby? o

    noes imagemagick! forgot to migrate... nice of you to mention those environment variables I apparently need to set yum install all --the --things brew uninstall patience mysqladmin -u wizard create blawg_development
  25. None
  26. script/bootstrap

  27. “Never send a README to do a setup script’s job.”

    @trek Trek Glowacki
  28. script/bootstrap dependency checks bundler database setup does your job

  29. HOW IS SINATRA SERVER FORMED?* * http://cl.ly/ICAy

  30. ruby le_app.rb rackup -p 5000 thin --rackup config.ru start shotgun

    -p 5000 bieber_site.rb
  31. None
  32. script/server

  33. look familiar?

  34. script/console

  35. BONUS!

  36. know how to get a console to sinatra on heroku?

  37. maybe that’s a trick question

  38. maybe that’s a trick question (since it depends)

  39. heroku run script/console

  40. now you can!


  42. Furthe Reading

  43. Sinatra: Up and Running Alan Harris Konstantin Haase

  44. YOU develop your own conventions for building sinatra apps share

    them with the community
  45. Thanks!

  46. Asap, Omnibus Type Lavenderi , Lost Typ Menlo