GangstaGraham
GangstaGraham

Reputation: 9355

uninitialized constant Sinatra

I am unable to run my Sinatra application.

I get the following error:

application.rb:1:in `<main>': uninitialized constant Sinatra (NameError)

here is line 1 of application.rb:

class Application < Sinatra::Base

What am I doing wrong?

I have installed Sinatra as a gem.

Upvotes: 1

Views: 7138

Answers (2)

kgpdeveloper
kgpdeveloper

Reputation: 2119

Because, it's modular, it makes sense to use:

require 'sinatra/base'

There's a subtle difference. In most cases, you would really need:

require 'sinatra'

Upvotes: 2

sarahzrf
sarahzrf

Reputation: 330

Just installing a gem does not make it automatically loaded; you have to do that manually via require. Add require 'sinatra' before you do anything Sinatra-related and it should work.

Upvotes: 8

Related Questions