GithubHelp home page GithubHelp logo

what-is-sinatra's Issues

ENV["HOST_PORT"] returns nil

This lesson wasn't able to load up the sinatra server when a student did ruby app.rb. On as screen share I discovered that ENV["HOST_PORT"] was returning nil, most likely because this key was removed from or changed in ENV hash. I was able to get Sinatra to work by manually passing in an port number but this could potentially cause more issue for students in the future.

@aturkewi

Unable to start Sinatra server via ruby app.rb

When students run rackup or shotgun in the IDE to start a Sinatra server, the command is properly intercepted and routed on the backend. However, when students run ruby app.rb it isn't, and it results in the following failure:

[02:01:30] (master) sinatra-hello-world-basics-v-000                                            
// โ™ฅ ruby app.rb                                                                                
== Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from Thin           
Thin web server (v1.7.0 codename Dunder Mifflin)                                                
Maximum connections set to 1024                                                                 
Listening on localhost:4567, CTRL+C to stop                                                     
Stopping ...                                                                                    
== Sinatra has ended his set (crowd applauds)                                                   
/usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)                 
        from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_server'                                                                                 
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/backends/tcp_server.rb:16:in `connect'                                                                                     
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/backends/base.rb:63:in `block in start'                                                                                    
        from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run_machine'                                                                                  
        from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run'                                                                                          
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/backends/base.rb:73:in `start'                                                                                             
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/server.rb:162:in `start'   
        from /usr/local/rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in `run'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1506:in `start_server'                                                                                       
        from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1444:in `run!'                                                                                               
        from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'

Have to either change that functionality or the README for this lesson, which instructs students to start this web application by running ruby app.rb.

cc: @aturkewi

P.S.: Props to @mekowalski for (apparently) being the only student using the IDE to actually try to follow the instructions! ๐Ÿ˜†

Repeated clause

The last paragraph of Why Sinatra Before Rails has a duplicate clause: "a system for building web applications that governs 90% of the worlds' apps." It's in both the first and last sentence.

different terminal output for ruby 2.6.1

output looks like this

[2019-03-31 14:45:45] INFO WEBrick 1.4.2 [2019-03-31 14:45:45] INFO ruby 2.6.1 (2019-01-30) [x86_64-darwin18] [2019-03-31 14:45:45] INFO WEBrick::HTTPServer#start: pid=69165 port=9292 ^C[2019-03-31 14:45:55] INFO going to shutdown ... [2019-03-31 14:45:55] INFO WEBrick::HTTPServer#start done.

not
`$ rackup app.rb
Puma starting in single mode...

  • Version 3.10.0 (ruby 2.3.0-p0), codename: Russell's Teapot
  • Min threads: 0, max threads: 16
  • Environment: development
  • Listening on tcp://localhost:9292
    Use Ctrl-C to stop and not
  • Listening on tcp://localhost:9292
    Use Ctrl-C to stop
    ^C- Gracefully stopping, waiting for requests to finish
    === puma shutdown: 2017-11-15 09:41:19 -0500 ===
  • Goodbye!
    [00:01:11] (wip-lesson) what-is-sinatra
    $`

Sinatra RuntimeError

The lesson says after you do gem install sinatra and set up your app.rb to be (if you're on the IDE):

require 'sinatra'

# Add these two lines below if you're on the Learn IDE!
set :bind, ENV["HOST_IP"]
set :port, ENV["HTTP_PORT"]

get '/' do
  "Hello, World!"
end

Then when you run ruby app.rb you should have a running Sinatra server on SOME_IP:SOME_PORT, but instead, this is coming up:

// โ™ฅ ruby app.rb
== Sinatra (v2.0.0) has taken the stage on  for development with backup from Thin
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 67.205.130.239:8080, CTRL+C to stop
Stopping ...
== Sinatra has ended his set (crowd applauds)
/usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:530:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
        from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:530:in `start_server'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/backends/tcp_server.rb:16:in `connect'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/backends/base.rb:63:in `block in start'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:194:in `run_machine'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/eventmachine-1.2.5/lib/eventmachine.rb:194:in `run'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/backends/base.rb:73:in `start'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/thin-1.7.2/lib/thin/server.rb:162:in `start'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/rack-2.0.3/lib/rack/handler/thin.rb:22:in `run'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-2.0.0/lib/sinatra/base.rb:1522:in `start_server'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-2.0.0/lib/sinatra/base.rb:1456:in `run!'
        from /usr/local/rvm/gems/ruby-2.3.1/gems/sinatra-2.0.0/lib/sinatra/main.rb:26:in `block in <module:Sinatra>'

If I ran: echo $HTTP_PORT it showed up blank, so I tried substituting RACK_PORT and hard-coding a port# instead of HTTP_PORT, but just got the same message but for a different port.

Narrative issues

The overview- "How does Twitter have different pages for each of its 300 million users? How can AirBnB support over 40 million guests with over 1.5 million listings worldwide? All of this is possible because of web applications"- is never addressed again in the rest of the readme. It feels almost like a non sequitur

Answering that first in the "What's a Web Framework" section would ease the reader in better to the rest of the info in there, and might also motivate them to keep going further into the readme. Or can we make Web Frameworks its own separate Readme, and in there, you can compare Rails vs. Sinatra as well as why pedagogically, teaching Sinatra first makes sense.

I think then this Sinatra Readme can just cover them creating the simple Sinatra app, which while pedagogically not that useful maybe, will show them the "magic" of seeing something on the web.

Incorrect directions

Hello,

in the readme it says to comment out two lines if running from learn IDE... however, it only works when I uncommented the two lines.

Content to address for the Learn Qualifying Track

Since the last unit before the unit on Sinatra is on OO, there are a couple of knowledge gaps that should be addressed.

screen shot 2015-10-01 at 11 37 24 am

^^ Add "libraries of code" since having "libraries alone can be confusing.

screen shot 2015-10-01 at 11 40 55 am

Suggest Wikipedia or other link that explains DSL. Student won't know what Rack is or Rails. Also, can we assume that they know what a Full Stack Development Framework is?

screen shot 2015-10-01 at 11 42 47 am

^^ Unclear whether the student should actually make this file and run it.

screen shot 2015-10-01 at 11 44 08 am

^^ Will students know what "listening to HTTP requests" mean? Unclear what a port is and how port 4567 is the Sinatra default.

screen shot 2015-10-01 at 11 45 34 am

^^ Really unsure what this application structure is? Should it be broken apart a bit moer? Also, "modular style encapsulated by Controller Classes and booted via the config.ru Rack convention" makes no sense to me right now. In addition to tweaking the language slightly, could be worth mentioning that these things will be mentioned in the next readme.

@matbalez

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.