Sinatra

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Sinatra - Presentation Transcript

    1. Introduction to Sinatra
    2. About • Koen Van der Auwera • Co-founder 10to1 (http://10to1.be) • @atog • http://atog.be
    3. Sinatra Sinatra is a Domain Specific Language(DSL) for quickly creating web-applications in ruby. It keeps a minimal feature set, leaving the developer to use the tools that best suit them and their application.
    4. where to start sudo gem install sinatra
    5. Rack Rack provides an minimal interface between webservers supporting Ruby and Ruby frameworks.
    6. require “rubygems” require “sinatra” ruby yourapp.rb Sinatra will look for any Rack compatible server to run the app in.
    7. http://localhost:4567
    8. not_found do “whoops-a-daisy” end get “/” do “Hello FOSDEM!” end
    9. get “/” do erb :index end __END__ @@ index <h1>Hello FOSDEM</h1> ...or you can use a “views” folder
    10. Familiar Rails Stuff • Routing • params • before filter • helper methods • layout
    11. Routing “/:one/:two/:three” {\"two\"=>\"b\", \"three\"=>\"c\", \"one\"=>\"a\"} “/*/alot/*” {\"splat\"=>[\"a\", \"c\"]}
    12. before, helpers before do #whatever you want end helper do #all you helper methods end
    13. Layout Pretty much equals application.html.erb in Rails Provide your html and use <%= yield %>
    14. Public Use a “public” folder to store your stylesheets, javascript files and images
    15. Tests? Sure. require 'sinatra/test/unit class TestBla < Test::Unit::TestCase configure do set :views => File.join(File.dirname(__FILE__), \"..\", \"views\")) end def test_home get \"/\" assert_equal 200, @response.status assert @response.body.length > 0 end def test_submit post \"/submit\", {:q => \"foo\" } assert_equal 302, @response.status end end
    16. Deployment Apache + Passenger config.ru + public require “yourapp” set :environment, :production run Sinatra::Application
    17. Sinatra in action Go.

    + Koen Van der AuweraKoen Van der Auwera, 9 months ago

    custom

    1105 views, 1 favs, 3 embeds more stats

    Introduction to Sinatra @FOSDEM 2009

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1105
      • 1082 on SlideShare
      • 23 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 19
    Most viewed embeds
    • 18 views on http://atog.be
    • 4 views on http://www.atog.be
    • 1 views on http://feeds.feedburner.com

    more

    All embeds
    • 18 views on http://atog.be
    • 4 views on http://www.atog.be
    • 1 views on http://feeds.feedburner.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories