18
Your first Sinatra app Create a basic Sinatra web, in just 2 minutes ..or less

Your first sinatra app

Embed Size (px)

Citation preview

Page 1: Your first sinatra app

Your first Sinatra app

Create a basic Sinatra web, in just 2 minutes

..or less

Page 2: Your first sinatra app

Thursday, February 3, 2011

Mario Zaizar@ Twitter, Github, Facebook, **

Page 3: Your first sinatra app

Thursday, February 3, 2011 06:18pm(finished at) Mario Zaizar@ Twitter, Github, Facebook, *.*

Page 4: Your first sinatra app

ok, Sinatra?o_O

Page 5: Your first sinatra app
Page 6: Your first sinatra app
Page 7: Your first sinatra app

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

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

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

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

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

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

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

Make coffee. Step 2 to 18

Page 15: Your first sinatra app

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

That's easy :P

Page 17: Your first sinatra app

Links?

ruby langsinatra framework sinatra and bundler best way

Page 18: Your first sinatra app

Thanks!d(n_n)b

Download me http://bit.ly/dXJn1H

^C== Sinatra has ended his set (crowd applauds)