Your first sinatra app
-
Upload
rubyc-slides -
Category
Technology
-
view
2.074 -
download
2
Transcript of Your first sinatra app
Your first Sinatra app
Create a basic Sinatra web, in just 2 minutes
..or less
Thursday, February 3, 2011
Mario Zaizar@ Twitter, Github, Facebook, **
Thursday, February 3, 2011 06:18pm(finished at) Mario Zaizar@ Twitter, Github, Facebook, *.*
ok, Sinatra?o_O
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/
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..
Disadvantages
No Rails mystical magic, forgot it.Everything from scratch, only your needs.Isn't the best MVC frameworkNot so
popular, than others
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.
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!
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;
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
Make coffee. Step 2 to 18
Test your App!
Start the server.$ ruby rubyc.rb Open it$ open http://localhost:4567
Step 19 / 19
Click me!
That's easy :P
Links?
ruby langsinatra framework sinatra and bundler best way
Thanks!d(n_n)b
Download me http://bit.ly/dXJn1H
^C== Sinatra has ended his set (crowd applauds)