Download - Your first sinatra app
![Page 1: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/1.jpg)
Your first Sinatra app
Create a basic Sinatra web, in just 2 minutes
..or less
![Page 2: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/2.jpg)
Thursday, February 3, 2011
Mario Zaizar@ Twitter, Github, Facebook, **
![Page 3: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/3.jpg)
Thursday, February 3, 2011 06:18pm(finished at) Mario Zaizar@ Twitter, Github, Facebook, *.*
![Page 4: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/4.jpg)
ok, Sinatra?o_O
![Page 5: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/5.jpg)
![Page 6: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/6.jpg)
![Page 7: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/7.jpg)
Sinatra is.
Is a Ruby web frameworkIt's written in Ruby. dahIt's based in URLs, get, put, delete..
Sinatra is a very simple, yet powerful, Domain Specific Language (DSL) +RESTful
http://www.sinatrarb.com/
![Page 8: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/8.jpg)
Advantages
Its, 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..
![Page 9: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/9.jpg)
Disadvantages
No Rails mystical magic, forgot it.Everything from scratch, only your needs.Isn't the best MVC frameworkNot so
popular, than others
![Page 10: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/10.jpg)
Lets go!
Installing the core, yeah, we'll need rocks, stars, and mud
Create a folder, install ruby, group all the gems in a single gemset.
![Page 11: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/11.jpg)
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 --create
Reload your bash, let rvm bring the magic!
![Page 12: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/12.jpg)
Manage your gems with Gemfile and Bundler Install 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 'sinatra'
Use bundler to install and maintain them.$ bundle install;
![Page 13: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/13.jpg)
Create your App. $ touch rubyc.rb && gedit rubyc.rb
Paste: require 'sinatra' get '/' do "It works!" end get '/hi:name' do "Hello #{params[:name]}!" end
Step 1 / 19
![Page 14: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/14.jpg)
Make coffee. Step 2 to 18
![Page 15: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/15.jpg)
Test your App!
Start the server.$ ruby rubyc.rb Open it$ open http://localhost:4567
Step 19 / 19
Click me!
![Page 16: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/16.jpg)
That's easy :P
![Page 17: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/17.jpg)
Links?
ruby langsinatra framework sinatra and bundler best way
![Page 18: Your first sinatra app](https://reader034.vdocuments.site/reader034/viewer/2022052310/5560cc2cd8b42a08088b4a75/html5/thumbnails/18.jpg)
Thanks!d(n_n)b
Download me http://bit.ly/dXJn1H
^C== Sinatra has ended his set (crowd applauds)