Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Your first sinatra app


Published on

Published in: Technology
  • Be the first to comment

Your first sinatra app

  1. 1. Your first Sinatra app Create a basic Sinatra web, in just 2 minutes ..or less
  2. 2. Thursday, February 3, 2011Mario Zaizar@ Twitter, Github, Facebook, **
  3. 3. Thursday, February 3, 201106:18pm(finished at)Mario Zaizar@ Twitter, Github, Facebook, *.*
  4. 4. ok,o_O Sinatra?
  5. 5. Sinatra is.Is a Ruby web frameworkIts written in Ruby. dah Its based in URLs, get, put, delete.. Sinatra is a very simple, yet powerful, Domain Specific Language (DSL) +RESTful
  6. 6. AdvantagesIts, simple, only have what you need.Better performance than Rails. You can use gems. There is life beyond Rails.Templates, Views, supports *all of them. good for? API implmentations, quick demos, minimal applications, widgets..
  7. 7. DisadvantagesNo Rails mystical magic, forgot it.Everything from scratch, only your needs.Isnt the best MVC frameworkNot so popular, than others
  8. 8. Lets go!Installing the core, yeah, well need rocks, stars, and mud Create a folder, install ruby, group all the gems in a single gemset.
  9. 9. Define which ruby, your gemset name,and enable them by default.* rvm is your only friend.$ mkdir ~/rubyc/ && cd ~/rubyc;$ touch .rvmrc && open .rvmrc;Paste:rvm 1.9.1@rubyc --createReload your bash, let rvm bring the magic!
  10. 10. Manage your gems with Gemfile andBundlerInstall bundler, use a Gemfile to declare all your required gems,repositories, version locking stuff, etc.$ gem install bundler;$ touch Gemfile && open Gemfile;Paste :source :rubygemsgem sinatraUse bundler to install and maintain them.$ bundle install;
  11. 11. Step 1 / 19Create your App.$ touch rubyc.rb && gedit rubyc.rbPaste:require sinatraget / do "It works!"endget /hi:name do "Hello #{params[:name]}!"end
  12. 12. Step 2 to 18Make coffee.
  13. 13. Test your App! Step 19 / 19Start the server.$ ruby rubyc.rbOpen it$ open http://localhost:4567 Click me!
  14. 14. Thats easy :P
  15. 15. Links? ruby lang sinatra framework sinatra and bundler best way
  16. 16. Thanks! d(n_n)b ^C == Sinatra has ended his set (crowd applauds) Download me