In both page 8 and page 67, the contruction
if development? is used. On page 67, in a setting within a route, like this:
get '/environment' do if development? "development" elsif production? "production" elsif test? "test" else "Who knows what environment you're in!" end
Within my app I was not able to get this running, this resulted in
NoMethodError at /environment undefined method `development?'`
I found that it works if I prefix
.development (and the other envs) with
But I’m trying to figure out how/why?
If I start my program by defining it as a class like this:
class MyApp < Sinatra::Base
… I think it sort of makes sense that I have to refer to
But if this app is just plain route defs etc. after require ‘sinatra’, I’m having trouble grasping why, and how to run the code from the book unmodified?
(Yes, I’m a bit of a n00b.)