Your first sinatra app

2,336 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,336
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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) +RESTfulhttp://www.sinatrarb.com/
  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 http://bit.ly/dXJn1H

×