1
votes

I am new to Sinatra, and am learning it by following the README file. My ultimate goal is to create a modular application as described on the Sinatra Serving Modular Application page. Unfortunately, my application doesn't work - if I use config.ru it generates an error:

uninitialized constant Object::MyClass (NameError)  

and modifying the code to do:

run! if app_file == $0  

is not working as well. Below is my code:

my_app.rb:

require 'sinatra/base'
class MyApp < Sinatra::Base
    get '/' do  
            test  
    end  
    def test  
            return "Hello World!"  
    end  
end

config.ru:

require File.dirname(__FILE__)+'/my_app'  
run Myapp.new

The commands ruby config.ru and rackup -p 4567 are not working - I receive (NameError), as I mentioned before. Does anyone have any ideas? Thank you so much.

2

2 Answers

4
votes

OK, I should not be so silly to post a problem which is a typo error.
:(
Sorry guys.

run MyApp.new

1
votes

I have wrote a simple tutorial about this topic.

(no ads)3 http://codex.heroku.com/past/2011/2/15/sinatrabase_in_the_modulnd/